Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this Article

Table of Contents
maxLevel4
absoluteUrltrue

...

Design an Event Listener for Slack

...

Workspace Using Slack Snap Pack

In any enterprise ecosystem, receiving notifications is critical to carry out your daily tasks. Emails are no longer the preferred method of receiving notifications, especially when the notifications involve time-critical issues. Managers usually run on a time crunch; to  To fasten the decision-making process and deliver results, they you can configure an Event Listener in their the Slack workspace to cut through the clutter and get notified on items that need their immediate attention. This use case demonstrates how we you can use the Slack Snap Pack to route important events that are important to the manager into a custom channel created for this purpose.

Problem

In a real business case scenario, checking for going through all messages posted on the Slack Channel is time-consuming and owing to the the hectic schedule of managers leaves them with little time to go through all the messages posted on Slack. However they cannot miss . However, you cannot miss out on important updates that require their attention. 

Solution

Using Slack integration for your organization allows you to set up notifications to send messages to a Slack private channel or a specific user on Slack. We You can efficiently automate the process of listening to Slack events, configuring the events, and receiving alerts on your Slack Channel upon the trigger of events. This Pipeline pipeline demonstrates how we you can automate the process of receiving alerts on the private channel when these events are triggeredsame.

Parent Pipeline - Slack ListenerChild Pipeline - Process Event

Download the Slack Listener and Process Events Pipelines. 

Understanding the Slack Pipeline

Prerequisites

  • Create an app in your Slack Workspace that listens to the Slack instance.
  • Set the required scopes for the app. In this Use Case, we set the Bot and User Token scopes to perform the following actions:
    • Add read channels, read messages, and read users.
    • Add write messages and read channels.

Building this Pipeline involves the following key Key steps:

  1. Create a Private Channel in SackSlack.
  2. Subscribe to the Slack events.
  3. Create a Child Pipeline.

Create a Private Channel in Slack

Create a private (custom) channel named #my_alerts, . and add the necessary stakeholders who should must receive alerts for the given events.

Subscribe to Slack Events

We want to configure the following Configure two events and to receive alerts on the private channel when these the following events occur:

  • Event 1: When a new member joins the Slack channel.
  • Event 2: When a SWAT ticket (customer-raised ticket) is posted in the channel.

To subscribe events in Slack:

  1. Navigate to https://api.slack.com/apps—Slack Apps page.
    to the Slack Apps page.

  2. Click Create New App.

    Image Added

  3. Select From scratch.

  4. Specify the App Name and choose a workspace to develop your app.
    Image Added

  5. Click Event Subscriptions in the left navigation pane.
    Image Added

  6. Enable the toggle for Enable Events.

  7. Subscribe to the events you want to listen .to:
    • Bot events: Whenever a bot performs the operation of adding adds a user to the channel, we want to receive an alert.
    • User events: Whenever a user posts a message to a public channel, private channel, individual user or , multiple users, or group of users, we want to receive an alert.

  8. Integrate the app with the channel. Follow one of the following ways to integrate the app with the channel:
    • Click the channel name to open the get channel details dialog. Navigate to the Integrations tab. In the Apps section of the Integration tab, click Add an App. Click Add next to the required app from the Add apps to channel_name dialog to integrate that app with the channel.
    • Alternatively, type /app in the messaging text box to get the option to Add apps to the channel. Select Add apps to the channel to open the Add apps to dialog. Click Add next to the required app from the Add apps to channel_name dialog to integrate that app with the channel.

  9. Provide the URL of the triggered task of the Parent Pipeline in the Request URL field.
    To provide the Request URL in Slack app, you need to configure  Configure a Pipeline with a Mapper Snap and create a triggered task to provide the Request URL in the Slack app.

Create a Parent Pipeline 

First, we configure the Mapper Snap with an expression to determine if the object is a challenge or an event.

...

Info
iconfalse
titleExpression

This expression includes three elements: Token, Challenge and Type.

  • If the element is a challenge, the Snap sends the JSON response containing the challenge.
  • If the element is an event, the Snap checks whether it is Retry, because most often the Pipeline pipeline might take more time to process events. Hence, if the Slack application does not get response in three seconds, the Snap retriggers the Pipelinepipeline.
  • If it is a retry, the Snap sends the JSON object without processing it. If it is a not a retry, the Snap sends the event for further processing.

...


Triggered Task

Create a a triggered task for the Parent Pipelinepipeline. From the Triggered task dialog window, we copy the Cloud URL and HTTP Header (token) and paste it in Request URL field in the Slack app for verification.

...

Once the Slack app receives the challenge from the Parent Pipeline, the URL is verified. After the URL is verified which usually takes three seconds, the request triggers the Parent Pipeline and it receives the challenge as response.
Image RemovedImage Added


Note

The Redirect URL should correspond to the same URL used for event subscription for the Slack app to function with the Slack Snap Pack.

...

If the input is a challenge, the Pipeline processes and sends the response. If the input is an event, the Router Snap routes the output to the Pipeline Execute Snap that runs the child Pipeline to process the event in the Process_Event Pipeline.

Next, we use the Join Snap to join both the output views of Pipeline Execute and Mapper Snaps using left outer join to get a unified output.

Create a Child Pipeline to Process Events

Image Modified

We configure the child Pipeline to perform the following two operations:

...

Finally, we configure the Join Snap to get a single output from the two output views. This output is the output of the Pipeline Execute Snap in the Parent Pipeline.

Downloads

Info

Important steps to successfully reuse Pipelines

  1. Download and import the pipeline into SnapLogic.
  2. Configure Snap accounts as applicable.
  3. Provide pipeline parameters as applicable.


Attachments
patterns*.slp, *.zip *.rar

...