Slack Integration
This tutorial integrates a Slack interface into Solace Agent Mesh, enabling interaction with the system directly from your Slack workspace and channels.
Read about Gateways before you start this tutorial.
Setting Up the Environment
First, you need to install Solace Agent Mesh and Solace Mesh Agent (SAM) CLI, and then create a new Solace Agent Mesh project or create a new gateway plugin.
Creating the Slack App
Next, create a Slack Application in your workspace.
- Go to the Slack Application website.
- Select Your Apps and click Create New App.
- Choose From a manifest and apply the following configuration.
- You can customize the name and description, but keep the rest of the configuration and settings unchanged.
display_information:
name: solace-agent-mesh-bot
description: An app to integrate with Solace Agent Mesh
features:
app_home:
home_tab_enabled: false
messages_tab_enabled: true
messages_tab_read_only_enabled: false
bot_user:
display_name: Solace Agent Mesh
always_online: false
oauth_config:
scopes:
bot:
- app_mentions:read
- bookmarks:read
- channels:history
- channels:join
- channels:manage
- channels:read
- chat:write
- chat:write.customize
- chat:write.public
- files:read
- files:write
- groups:history
- groups:read
- groups:write
- im:history
- im:read
- im:write
- links:read
- links:write
- mpim:history
- mpim:read
- mpim:write
- pins:read
- pins:write
- reactions:read
- reactions:write
- reminders:read
- reminders:write
- team:read
- usergroups:read
- usergroups:write
- users.profile:read
- users:read.email
- users:read
- users:write
- conversations.connect:read
- conversations.connect:write
- incoming-webhook
settings:
event_subscriptions:
bot_events:
- app_mention
- message.groups
- message.im
interactivity:
is_enabled: true
org_deploy_enabled: false
socket_mode_enabled: true
token_rotation_enabled: false
Then select Create
to create your new App.
App-Level Tokens
In your created App, select Basic Information
under Settings
. Scroll down to App-Level Tokens
and click Generate Token and Scopes
.
Provide your token a name, add all available scopes, and then click Generate
.
Make note of the resulting application token (beginning with xapp-
) - you need it in a future step.
Installing the App in Your Slack Workspace
Next, select Install App under Settings and follow the installation flow to install the App in your workspace.
After installation, the bot token (beginning with xoxb-
) is visible. Make note of this token.
Installing the Slack Gateway
After configuring your Slack App, the next step is to add the Slack gateway to Solace Agent Mesh.
-
Add the gateway plugin using the Solace Agent Mesh (SAM) CLI:
sam plugin add slack-bot --plugin sam-slack
You can change
slack-bot
to any name you prefer for your gateway. -
Configure the required environment variables:
The Slack interface requires two authentication tokens. Add these to your
.env
file in the project root directory using the tokens generated during Slack App setup:SLACK_BOT_TOKEN=xoxb-xxxxxxxxxx
SLACK_APP_TOKEN=xapp-xxxxxxxxxx
You can further customize the Slack gateway by updating the configs/gateways/slack-bot.yaml
file. This file contains the configuration for the Slack gateway, including the initial status message, the gateway system purpose, and response format.
Running the Slack Gateway
Launch the Slack gateway with:
sam run configs/gateways/slack-bot.yaml
For detailed information about available SAM CLI commands, see Solace Agent Mesh CLI.
Testing the Installation
To test your installation:
- Open your Slack workspace in the desktop app or browser.
- Find and click on the Solace Agent Mesh app under the Apps section.
- Send a test message by typing
hello
and click Enter. - You should see:
- A "Chatbot is thinking..." status message
- A response from the chatbot within a few seconds