Custom modules for Generic Agent

English! place to talk about development, programming and coding
Post Reply
mjunghanns
Znuny newbie
Posts: 4
Joined: 23 Oct 2023, 13:57
Znuny Version: 6.1
Real Name: Mark Junghanns

Custom modules for Generic Agent

Post by mjunghanns »

Hello there,
I migrated our OTRS CE 6.0.17 over to Znuny 6.1.2 a few days ago.

In our OTRS environment I have a php script which is triggered by the CMD option of a generic agent job each time, a TicketCreate event occurs. The php script is then sending a SOAP-request (containing the TicketNumber) to a SOAP webservice which will result in a NextCloud-share being created. I know that this is probably not the most elegant way to accomplish this, but this is working flawlessly for years.

As I was going over the Znuny 6.x release notes I learnt, that as of v6.3.x it will not be possible to run scripts this way anymore, the CMD - will then disappear. This was when I realized that I better learn how to implement a custom module.

Today is day 3 that I am trying to find any examples, documentation, recommendations on how to write a custom module, yet to no avail. I find it quite difficult as many websites that google comes up seem to be helpful at first but then link to some outdated or dead links in old and meanwhile unavailable OTRS forums. The developer documentation of Znuny doesn't contain what I am looking for either.
I have to admit that I am not a Perl professional but I think that if I had an example I could implement everything I need. The "how do I do the SOAP-request to my NextCloud" is not the issue - I figured that out already ;)

I would greatly appreciate if someone could point me into the right direction where and how to start. Any links to resources that could help me would be fine. My questions are in particular:
- What is the process when implementing a module? Does it have to be registered in any way?
- How would you debug your module? Currently my first attempts seem to sporadically not being properly processed but can't find out why.
- Is there any example module exist for the purpose of being used in the Generic Agent?

Thank you!
root
Administrator
Posts: 3968
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Custom modules for Generic Agent

Post by root »

Hi,

Starting with the version where CMD can't be configured via the GUI is an example file available: https://github.com/znuny/Znuny/blob/rel ... on.pm.dist

1. Copy this file and choose a name that matches the use case, without the .dist
2. Update the line starting with package according to your new filename
3. Choose one of the possible ways to start an external command. Line 36 shows an example without ticket number, 39 with ticket number as param. Only one of the is needed.
4. Use the module in the GenericAgent Kernel::System::GenericAgent::YOURNAME

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
mjunghanns
Znuny newbie
Posts: 4
Joined: 23 Oct 2023, 13:57
Znuny Version: 6.1
Real Name: Mark Junghanns

Re: Custom modules for Generic Agent

Post by mjunghanns »

Hi Roy,

thank you so much - this is addressing exactely the issue I am dealing with! :)

As this solution will give me more time in the meantime, I will try to learn how to rewrite the "old" scripts functionalities in a perl module.

Regards,
Mark
root
Administrator
Posts: 3968
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Custom modules for Generic Agent

Post by root »

Hi,

Why don't you use the web service of Znuny to perform the web request?

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
mjunghanns
Znuny newbie
Posts: 4
Joined: 23 Oct 2023, 13:57
Znuny Version: 6.1
Real Name: Mark Junghanns

Re: Custom modules for Generic Agent

Post by mjunghanns »

Sorry for the late reply, Roy.

You are right - I will switch to using the web service of Znuny. I just have little time to learn how to do this right now. I will focus on doing that once I have migrated from OTRS to Znuny.
Post Reply