faiberts
6/19/2017 - 1:19 AM

otrs2mattermost.sh

#!/bin/bash

# This is a script to send a notification from OTRS to Mattermost.
# Create a new Generic Agent and select "TicketCreate" under event based events.
# Finally, put in the path to the script into the command box.
# Of course you could use it for different notifications, but OTRS is only giving the ticket number and id to the script.

header="Content-Type: application/json"
ticketid=$2
request_body=$(< <(cat <<EOF
{
  "username": "OTRSbot",
  "text": "**New Ticket!** <http://host.of.otrs/otrs/index.pl?Action=AgentTicketZoom;TicketID=$ticketid>",
  "icon_url": "http://host.of.otrs/otrs-web/skins/Agent/default/img/icons/apple-touch-icon.png"
}
EOF
))

curl -i -X POST -H "$header" -d "$request_body" http://host.of.mattermost/hooks/WebHookKey