{{announcement.body}}
{{announcement.title}}

Serverless Integration Between Slack and Twilio Using Kumologica

DZone 's Guide to

Serverless Integration Between Slack and Twilio Using Kumologica

Building a serverless service incident notification API using Kumologica.

· Integration Zone ·
Free Resource

When a server goes down, or a critical issue is reported by your customers — your team swings into action but, you have to contact your team promptly. SMS and Voice calls are two channels of communication that are popular for alerting and notification.

In this article, we will be creating an IncidentNotification API intelligent enough to decide based on incident severity to send SMS or a voice call to the support engineers using Twilio cloud messaging platform. We will be building the API using Kumologica. Kumologica is a free low-code development tool to build serverless integrations. You can learn more about Kumologica in this medium article or subscribe to our YouTube channel for the latest videos.

Use Case

In this use case, we have an IT service desk operator who will be receiving a call from the customer regarding an issue with the application. The service desk operator takes the details and raises a ticket on the ITSM (IT service management) tool and gets the ticket number. The IT service desk operator then uses the Slack channel to notify the support engineer. In order to notify the service desk operator types the following slack command in the channel /ticket <<ticket number>>.

The API will fetch the support engineer contact number and severity of the incident using the ticket number from ITSM datastore. In this use case we will assume DynamoDB as the ITSM datastore. Now if the severity of the incident is P3 or P2 the flow will route the call to Twilio for sending a SMS with a specific ticket details. If the severity is P1 then route the call to Twilio for making a voice call with a specific message.

High-level use case flow

                                                              High-level use case flow

Prerequisite

  1. Kumologica designer installed in your machine. https://kumologica.com/download.html
  2. Twilio platform Account
  3. Slack Account
  4. DynamoDB with the following records.

The emp_contactno should be verified numbers in your Twilio account.

DynamoDB table structure

Implementation

In order to implement the incident notification API we will be following the below-given logic:

Rule logic flow


  1. Open Kumologica Designer, click the Home button and choose Create New Kumologica Project.
  2. Enter the name (for example IncidentNotificationAPI), select directory for project and switch Source into From Existing Flow.
  3. Copy and Paste the following flow
  4. Press Create Button.

Install the Twilio Node

A Twilio node is a contribution node and must be explicitly installed in Kumologica Designer. Press Add more nodes button located in the bottom left corner of the designer. You will be presented screen with all contribution nodes that are currently available. Choose Twilio node, press Install button. After few seconds, plugin will be installed and you will be prompted to restart Kumologica Designer. Twilio node will be located under new category: Platforms after restart.

Add More nodes panel

You should be seeing two flows as given below on the designer canvas.

The first flow is the API endpoint with the resource path /ticket. This flow accepts the request from Slack and makes a call to DynamoDB(ITSM) to fetch the ticket details. The ticket details is then published to a Amazon SQS queue. This is done as an event driven model in order to respond back to Slack quickly (the default timeout of Slack is 3 second).

Incident notification API flow

The second flow having the rule logic to decide whether to send SMS or voice call. The ticket details are fetched from the SQS using EventListener node and based on the ticket severity appropriate route will be taken to invoke Twilio to send an SMS or a voice call.

Rule Logic flow

Note: To try out the above flow ensure to furnish the settings of Twilio node, SQS node and AWS DynamoDB node with appropriate connection configuration.

Deploy Flow to AWS Lambda

Select the CLOUD tab on the right panel of Kumologica designer, choose AWS Profile and press Deploy button. This will trigger build and deployment of flow into AWS Lambda. On the trigger section you need to add to triggers.

  1. API Gateway
  2. Amazon SQS

API gateway and SQS trigger

Once deployed you have to configure the endpoint with Slack command. In order to configure the Slack command (/ticket) you can refer to this link

Testing

  1. Type in your Slack channel the following command /ticket <<ticket number>>. The ticket number should match the ticket number stored in the DynamoDB.
  2. When the command entered, following response will be visible as response on Slack channel window.
Slack command

  3. Based on the severity associated with the ticket number SMS or voice call will be received from Twilio platform.

Conclusion

This article presented how easy Kumologica Designer flow orchestrates and integrates with Twilio platform using Twilio node. Within few minutes we have created and deployed the incident notification Kumologica flow and configured the API endpoint with Slack.

Remember Kumologica is totally free to download and use. Go ahead and give it a try, we would love to hear your feedback.

In the meantime, if there is any specific use case that you would like to see in a future article please let us know in the comments section.

Topics:
aws, aws lambda, integration, low code, microservice, serverless, twilio

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}