Integrating Slack With Mule 4

DZone 's Guide to

Integrating Slack With Mule 4

This article talks about how to stream from Slack using their API in Mule ESB.

· Integration Zone ·
Free Resource

Slack app

Integrating Slack With Mule 4

Slack is a cloud-based application that provides real-time messaging, archiving, search, persistent chat rooms, and more. Mulesoft has a connector for Slack. The Slack connector provides 2-way integration between the Slack messaging system and others in Mule ESB.

This article talks about how to do streaming from Slack using their API in Mule ESB.

First of all, you will need to create a Mule project. Anypoint Studio Version: 7.3.4 and Mule Runtime 4.2.0 EE is used for the below examples.

We will also need the Slack connector.

How to Install Slack Connector in Anypoint Studio

Go to Help→ Install new software

In the work with field enter the url connector repository

Connector: https://repository.mulesoft.org/connectors/releases/3.5.0

Enter “Slack” in the filter field.

You may also like:  The 7 Best Slack Integrations and Add-ons of 2019

Setup and Configuration

Select the Slack connector and proceed. You will be able to see the Slack connector in the Mule Palette.

After adding the Slack connector, you will have to configure Slack. There are two ways to configure Slack

  1. Token Connection
  2. OAuth2 Connection

I have used Token Connection for this demo. You are free to choose which one to use.

Go through the Slack API documentation to generate token.

Sign in with your Slack account and create the token.

The URL to create the token is https://api.Slack.com/custom-integrations/legacy-tokens

Once you receive the token, return to Anypoint Studio and open the Slack config.

Once you select the Slack module, you will see a number of operations that you can do.

Application Setup in Mule 4:

How do we receive a new message from a particular channel or a group?

It will show you all the available channels and group names that are there in your organization. Select the name from the drop-down list.

To get the user information and group information like from whom you are receiving messages and from which group they are coming, you need to configure user information and group information.

XML Code screenshot for reference:

Image title

Example of the conversation stored in a text file.

Thanks for reading!

Further Reading

Comparing the Slack Discovery API With the Web API

Slack’s Real-Time Messaging API Events

anypoint studio, integration, mule, mule 4, mule esb, slack, slack connector, slack integration

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}