Post a Message to Slack

This post function/listener allows you to send a personalized custom message to your Slack room.  When configuring a post function there are bindings for the issue object. When configuring a listener there are bindings for the issue object and event object.

For example, you want to be notified in a Slack channel when an issue is moved to Done and what the resolution is set to.

Please note that the event object is only available when configuring a listener. If you are configuring a post function you should remove the event object from your message template.  

"Issue $issue resolved with resolution <% out << issue.resolution?.name %>. by <% out << event.getUser() %>"
  1. Select the Post a Message to Slack post function/listener.

    For details on how to navigate to ScriptRunner workflow functions, see Navigating to Workflow Functions.

  2. Enter a description of the post function/listener in Note
  3. If you're configuring a listener, select an event from the drop-down list.
  4. Enter your bearer token to retrieve a list of target rooms (channels) you can post to.

    For details on how to create Slack apps and tokens, see Create Slack App.

  5. Select the target room (channel) you want to post to.
  6. Enter a condition if you want to conditionally send the slack message, or leave this field empty to always send on transition.
  7. Enter a message to send. See below for guidance on creating your message template.

String templating in groovy

There are two variables available for you to use in your template, "issue" and "event". This last one is only available if you configure this feature as a listener.

Check the documentation about constructing your string template for the last field of the form:

As a summary, in order to call a property, you can call it with the name

"Your issue $issue has been updated."

But you can do more complex calls to your object by using the <% %> notation:

"Your Issue $issue was updated by <% out << event.getUser() %> on <% out << event.getTime() %>."