You must enable javascript in order to use the Slack API Documentation. You can do this in your browser settings.
Go to Slack

Making notifications actionable

Use cases:
  • Confirmation workflows
  • Alert acknowledgment
Works with:
  • Events API
  • Message Buttons
Code samples:

When a helpdesk ticket is created in a 3rd party system, send an actionable notification in Slack that allows the user to claim the ticket or apply a label.

How it works

Actionable notifications, illustrated

This app blueprint assumes that your 3rd party ticketing system has outgoing webhooks i.e. it sends an HTTP request to a customizable URL when certain events happen. If your helpdesk system does not have outgoing webhooks, you may be able to periodically poll for new tickets and follow the process described below.

1. Set up an endpoint to receive webhooks for new tickets

The app has an endpoint (/new-ticket) that receives webhooks from the ticketing system whenever a new ticket is created. This app blueprint takes a simplistic approach in assuming that there is only one endpoint for all types of tickets and that the notifications are pushed into Slack using a single incoming webhook. For more complex systems, consider using a bot that generates a webhook per channel.

2. Process helpdesk webhooks

When a webhook is received from your ticketing system, the details of the ticket (such as the title, description, date, author and assignee) are parsed out of the JSON payload. These details are passed into a message template for the Slack notification. The template places the details into a well-formatted Slack message that has author, title, text and attachment fields. A set of actions (a message button and multiple message menus) are also added to the message. The callback ID of each message action is set to the ticket ID in the 3rd party system so that any actions a user takes on Slack can be mapped back to the 3rd party system.

To include message actions, you'll need to enable Interactive Messages in the app settings and supply a URL where Slack can send the button click event.

3. Send the notification to Slack

Post the message to Slack using an incoming webhook URL. Incoming Webhooks are a simple way to post messages, normal HTTP requests with a JSON payload, from external sources into Slack. The incoming webhook URL for your app is available in the app settings after enabling the feature and installing the app on a team.

4. Handle button clicks and menu selections

If the user clicks on a button or makes a selection from a menu in the message, Slack will send a POST request to the Interactive Message request URL provided in the app settings. This request will include a callback_id, a response_url and information about the user who took the action. The callback_id (which was previously set to be the same as the ticket ID) can be used to map the action back to a specific ticket. The app will leverage your ticketing system's API to make the necessary updates. Once the update has completed, a status update can be sent back to Slack using the response_url. The response_url allows the app to update the content of the message the action was taken on using an HTTP request with a JSON payload.

The account binding template will help you bind Slack users to users in your 3rd party system to ensure that all existing authorizations are well respected.

Diagram

A flow diagram detailing actionable notifications

Other use cases

  • Assign project management tasks

Related documentation