Post Ticket Events to Slack Channels
Robert Ullrich19. Sep 2018 | Case studyConsultingCyber SecurityUse cases
The practical examples presented in our technical blog (blog.otrs.com) and now in the expert category in our FAQ blog section serve as a source of ideas and documentation to show what is theoretically possible with OTRS in concrete scenarios or sometimes even for more exotic configurations. All configurations presented here were developed under laboratory conditions as a proof of concept.
We can only guarantee testing and implementation of these concepts to be error-free and productive if implemented in a workshop with one of our OTRS consultants. Without this, the responsibility lies with the customer himself. Please note that configurations from older OTRS versions may not work in the newer ones.
During my vacation, I thought about new integration use cases I can show you. Because I’m also evaluating Phantom at the moment and was invited to join their Slack community, I thought this would be a nice use case. So let’s start with our “SlackConnector”.
Like in former blog posts, there are several requirements for this HowTo:
- running OTRS 6.0.x system
- a valid Slack workspace
Prepare Slack for the integration
Follow the instructions and create a new incoming webhook.
Configure the SlackConnector on OTRS side
At first, we’ve to create the new web service.
Afterward, we need a new invoker. Attached you’ll find the first part of my config:
The most important part is (as always) the XSLT mapping. The following example is tested and working:
Here’s the XSL stylesheet:
<?xml version="1.0" encoding="UTF-8" ?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" /> <xsl:template match="RootElement"> <xsl:copy> <text>New Ticket [Ticket#<xsl:value-of select="//TicketNumber"/>] created! Title: <xsl:value-of select="//Ticket/Title"/> Priority: <xsl:value-of select="//Ticket/Priority"/> </text> <attachments> <title>https://storm-demo.managed-otrs.com/otrs/index.pl?Action=AgentTicketZoom;TicketID=<xsl:value-of select="//TicketID"/></title> <title_link>https://storm-demo.managed-otrs.com/otrs/index.pl?Action=AgentTicketZoom;TicketID=<xsl:value-of select="//TicketID"/></title_link> <text>Go to ticket to see more information!</text> </attachments> <attachments/> </xsl:copy> </xsl:template> </xsl:transform>
The last part for the invoker is the used event trigger. Because I want to inform my Slack users every time when a new ticket is created, I’m using the “TicketCreate” event without any event filters:
That’s all for the invoker configuration. The next part is the configuration of the transport. I’m using a small workaround to make the integration possible. My Slack token is “T0X829D7E/BBYH0BEE4/nAFuXxXxXxXxXxXxXxXxXxX2”. I’ve added the first part until the “/” to my endpoint address and the second part including the “/” I added to the controller mapping. Don’t forget to set “POST” as request command.
Apply all changes. Congratulations! You’re done with the invoker.
Test the SlackConnector
Let’s test our new web service. Create a new ticket and see if the invoker is triggered:
The output in the OTRS debugger should look like the following:
Because of the received JSON data from Slack, we should also see the message now in our Slack channel
More information about the Slack REST API
You can also use other resources which are provided by the Slack REST API.
Please go to the following website, if you need more information: https://api.slack.com/web