[Solved] Znuny 6.1.2 - Slack Integration - Webservice

Moderator: crythias

Post Reply
Reedu
Znuny newbie
Posts: 29
Joined: 11 Mar 2013, 15:08
Znuny Version: Znuny 6.1.2
Real Name: Adam

[Solved] Znuny 6.1.2 - Slack Integration - Webservice

Post by Reedu »

Hi
I'm trying to make simple integration with slack. Nothing too fancy - just notifing about new tickets and new articles.
So i've made an WS with two Ticket:Generic Invokers (similar to example on blog.otrs.com)
First one for xlst with information about created ticket - running on event TicketCreate
Second one for information about new articles - running on events: notification followUp and notification addNote.

First one is working - it's posting messages to slack channel.
In debuger i've got:
- Communcation sequnce started
- Using invoker 'xxxx'
- Outgoing data before mapping
- Outgoing data after mapping
- ... and so on.

But second one just does not...
In debuger i can see just those two messages:
- Communcation sequnce started
- Using invoker 'xxxx'

There's no error in system log. If anyone could point me into right direction i'd be gratefull.
Last edited by Reedu on 27 Oct 2021, 09:11, edited 1 time in total.
root
Administrator
Posts: 3934
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Znuny 6.1.2 - Slack Integration - Webservice

Post by root »

Hi,

Some errors never make it into the webservice log. Did you checked the application log?

- 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 ?
Reedu
Znuny newbie
Posts: 29
Joined: 11 Mar 2013, 15:08
Znuny Version: Znuny 6.1.2
Real Name: Adam

Re: Znuny 6.1.2 - Slack Integration - Webservice

Post by Reedu »

If you mean system log in administration module - yes. There's nothing.
It looks like invoker is dying or stopping... i'll try to run tcpdump to catch all packets. It's my test system so i can do almost anything.
If it won't show me anything i'll try to edit Kernel/GenericInterface/Invoker/Ticket/Generic.pm to catch why it's not working - or it's not right file?
... then again maybe i've misunderstood WS invoker configuration? It should have always ticket data but run on specific configured event?
Maybe it's not firing becouse of chosen events?
root
Administrator
Posts: 3934
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Znuny 6.1.2 - Slack Integration - Webservice

Post by root »

Hi,

Check the Znuny log and maybe the apache error_log. Set the sysconfig MinimumLogLevel to debug and see what's in the log. tcpdump and fiddeling in files should be the last resort.

If you would share your configuration helping would be way easier.

- 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 ?
Reedu
Znuny newbie
Posts: 29
Joined: 11 Mar 2013, 15:08
Znuny Version: Znuny 6.1.2
Real Name: Adam

Re: Znuny 6.1.2 - Slack Integration - Webservice

Post by Reedu »

I've set MinimumLogLevel and still no luck with articles.

Adding new internal note do nothing.

Code: Select all

[Fri Oct  8 14:27:54 2021][Debug][Kernel::System::Web::InterfaceAgent::Run][1161] Response::Agent: 0s taken (URL:Action=AgentTicketNote;TicketID=181097:akrol)
[Fri Oct  8 14:27:59 2021][Debug][Kernel::System::Web::InterfaceAgent::Run][1161] Response::Agent: 0s taken (URL:Action=AgentTicketNote&Subaction=Store:akrol)
[Fri Oct  8 14:28:00 2021][Debug][Kernel::System::Web::InterfaceAgent::Run][1161] Response::Agent: 1s taken (URL:Action=AgentTicketZoom;TicketID=181097;ArticleID=1092820:akrol)
[Fri Oct  8 14:28:00 2021][Debug][Kernel::System::Web::InterfaceAgent::Run][1161] Response::Agent: 0s taken (URL:Action=AgentTicketArticleContent;Subaction=HTMLView;TicketID=181097;ArticleID=1092820;FileID=;:akrol)
[Fri Oct  8 14:28:00 2021][Debug][Kernel::System::Web::InterfaceAgent::Run][1161] Response::Agent: 0s taken (URL:Action=AgentTicketZoom&Subaction=LoadWidget:akrol)
[Fri Oct  8 14:28:03 2021][Debug][Kernel::System::Web::InterfaceAgent::Run][1161] Response::Agent: 0s taken (URL:Action=AgentTicketZoom&Subaction=MarkAsSeen:akrol)
I'll add some more loging function into files - and post result later.
--------------
I'm runnig Znuny on:

Debian GNU/Linux 10 (buster)
postgres: 13

WS definition exported below. Of course host/controller are hidden :)
Anybody can import it - create is working

Code: Select all

---
Debugger:
  DebugThreshold: debug
  TestMode: '0'
Description: ''
FrameworkVersion: 6.1.2
Provider:
  Transport:
    Type: ''
RemoteSystem: ''
Requester:
  Invoker:
    ArticleCreated:
      Description: ''
      Events:
      - Asynchronous: '1'
        Condition:
          Condition:
            '1':
              Fields:
                SenderType:
                  Match: customer
                  Type: String
              Type: and
            '2':
              Fields:
                SenderType:
                  Match: agent
                  Type: String
              Type: and
          ConditionLinking: or
        Event: NotificationFollowUp
      - Asynchronous: '1'
        Event: NotificationAddNote
      MappingOutbound:
        Config:
          DataInclude: []
          ForceArray: ''
          PostRegExFilter: ~
          PostRegExValueCounter: ~
          PreRegExFilter: ~
          PreRegExValueCounter: ~
          Template: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<xsl:transform
            version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:date=\"http://exslt.org/dates-and-times\"
            extension-element-prefixes=\"date\">\r\n    <xsl:output method=\"xml\"
            encoding=\"utf-8\" indent=\"yes\"/>\r\n    <xsl:template match=\"RootElement\">\r\n
            \       <xsl:copy>\r\n           <blocks>\r\n               <type>section</type>\r\n
            \              <text>\r\n                   <type>plain_text</type>\r\n
            \                  <text>New article has been created for ticket: <xsl:value-of
            select=\"//Ticket/TicketNumber\" /></text>\r\n               </text>\r\n
            \          </blocks>\r\n        </xsl:copy>\r\n    </xsl:template>\r\n</xsl:transform>"
        Type: XSLT
      Type: Ticket::Generic
    TicketCreate:
      Description: ''
      Events:
      - Asynchronous: '1'
        Event: TicketCreate
      MappingOutbound:
        Config:
          DataInclude: []
          ForceArray: ''
          PostRegExFilter: ~
          PostRegExValueCounter: ~
          PreRegExFilter: ~
          PreRegExValueCounter: ~
          Template: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<xsl:transform
            version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:date=\"http://exslt.org/dates-and-times\"
            extension-element-prefixes=\"date\">\r\n    <xsl:output method=\"xml\"
            encoding=\"utf-8\" indent=\"yes\"/>\r\n    <xsl:template match=\"RootElement\">\r\n
            \       <xsl:copy>\r\n           <blocks>\r\n               <type>section</type>\r\n
            \              <text>\r\n                   <type>plain_text</type>\r\n
            \                   <text>New ticket has been created for&#x20;<xsl:value-of
            select=\"//Ticket/CustomerUserID\" />&#x20;//&#x20;<xsl:value-of select=\"//Ticket/CustomerID\"
            />&#x20;</text>\r\n               </text>\r\n               <accessory>\r\n
            \                  <type>button</type>\r\n                   <text>\r\n
            \                      <type>plain_text</type>\r\n                       <text>\r\n
            \                          <xsl:value-of select=\"//Ticket/TicketNumber\"
            />\r\n                       </text>\r\n                   </text>\r\n
            \                   <value>click_me_123</value>\r\n                    <url>&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;/index.pl?Action=AgentTicketZoom;TicketID=<xsl:value-of
            select=\"//Ticket/TicketID\" /></url>\r\n                    <action_id>button-action</action_id>\r\n
            \                </accessory>\r\n            </blocks>\r\n            <blocks>\r\n
            \               <type>divider</type>\r\n            </blocks>\r\n            <blocks>\r\n
            \               <type>section</type>\r\n                <text>\r\n                   <text><xsl:value-of
            select=\"//Ticket/Articles/Body\" /></text>\r\n                   <type>plain_text</type>\r\n
            \               </text>\r\n           </blocks>\r\n        </xsl:copy>\r\n
            \   </xsl:template>\r\n</xsl:transform>"
        Type: XSLT
      Type: Ticket::Generic
  Transport:
    Config:
      AdditionalHeaders: ~
      ContentType: JSON
      DefaultCommand: POST
      Host: https://hooks.slack.com/services/SLACK_WEB_HOOK_PART_I_II
      InvokerControllerMapping:
        ArticleCreated:
          Command: POST
          Controller: /SLACK_WEB_HOOK_PART_III
        TicketCreate:
          Command: POST
          Controller: /SLACK_WEB_HOOK_PART_III
      SSLNoHostnameVerification: '0'
      Timeout: '120'
    Type: HTTP::REST
You do not have the required permissions to view the files attached to this post.
root
Administrator
Posts: 3934
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Znuny 6.1.2 - Slack Integration - Webservice

Post by root »

Hi,

Without importing the web service my guess is:

the condition does not match and the event might be wrong. Why don't you use ArticleSend/ArticleCreate events? And try for the field to check
'Jq#.Article.SenderType' or 'Article_SenderType'

- 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 ?
Reedu
Znuny newbie
Posts: 29
Joined: 11 Mar 2013, 15:08
Znuny Version: Znuny 6.1.2
Real Name: Adam

[Solved] Re: Znuny 6.1.2 - Slack Integration - Webservice

Post by Reedu »

I've tried this before and it also didn't worked - without additional conditions.
In my understanding, every event configured in invoker should call it.

So i see that invoker is called but that's all - message isn't posted.

---------------
The real problem was here:
Undefined subroutine &Kernel::System::Ticket::encode_base64 called at /opt/otrs/Kernel/System/Ticket.pm

encode_base64 is used in MIME::Base64, but it wasn't added to Ticket.pm
Putting just

Code: Select all

use MIME::Base64; 
worked like charm.


-------
Another tweak that was done, based on articles in otrs.ru, were changes in REST.pm becouse SLACK response isn't json.

~line 1032, after

Code: Select all

 # To convert the data into a hash, use the JSON module.
my $Result;
add

Code: Select all

    if ($ResponseContent eq 'ok' ) {
        $ResponseContent = '{"text": "ok"}';
    }
That's all.
root
Administrator
Posts: 3934
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: [Solved] Znuny 6.1.2 - Slack Integration - Webservice

Post by root »

Hi Reedu,

Thank you for reporting this as an issue. It's fixed in yesterdays 6.2.1 release.

- 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 ?
Post Reply