Slack
This documentation describes the integration of MindsDB with Slack, a cloud-based collaboration platform. The integration allows MindsDB to access data from Slack and enhance Slack with AI capabilities.
Prerequisites
Before proceeding, ensure the following prerequisites are met:
- Install MindsDB locally via Docker or Docker Desktop.
- To connect Slack to MindsDB, install the required dependencies following this instruction.
- Install or ensure access to Slack.
Connection
Establish a connection to Slack from MindsDB by executing the following SQL command and providing its handler name as an engine.
The Slack handler is initialized with the following parameters:
token
is a Slack bot token to use for authentication.app_token
is a Slack app token to use for authentication.
Please note that app_token
is an optional parameter. Without providing it, you need to integrate an app into a Slack channel.
Method 1: Chatbot responds in direct messages to a Slack app
One way to connect Slack is to use both bot and app tokens. By following the instructions below, you’ll set up the Slack app and be able to message this Slack app directly to chat with the bot.
If you want to use Slack in the CREATE CHATBOT
syntax, use this method of connecting Slack to MindsDB.
This connection method enables you to chat directly with an app via Slack.
Alternatively, you can connect an app to the Slack channel:
- Go to the channel where you want to use the bot.
- Right-click on the channel and select View Channel Details.
- Select Integrations.
- Click on Add an App.
Here is how to connect Slack to MindsDB:
It comes with the conversations
and messages
tables.
Method 2: Chatbot responds on a defined Slack channel
Another way to connect to Slack is to use the bot token only. By following the instructions below, you’ll set up the Slack app and integrate it into one of the channels from which you can directly chat with the bot.
Here is how to connect Slack to MindsDB:
Usage
The following usage applies when Connection Method 2 was used to connect Slack.
See the usage for Connection Method 1 via the CREATE CHATBOT
syntax.
Retrieve data from a specified table by providing the integration and table names:
Supported Tables
The Slack integration supports the following tables:
conversations
Table
The conversations
virtual table is used to query conversations (channels, DMs, and groups) in the connected Slack workspace.
messages
Table
The messages
virtual table is used to query, post, update, and delete messages in specific conversations within the connected Slack workspace.
You can also find the channel ID by right-clicking on the conversation in Slack, selecting ‘View conversation details’ or ‘View channel details,’ and copying the channel ID from the bottom of the ‘About’ tab.
threads
Table
The threads
virtual table is used to query and post messages in threads within the connected Slack workspace.
users
Table
The users
virtual table is used to query user information in the connected Slack workspace.
Rate Limit Considerations
The Slack API enforces rate limits on data retrieval. Therefore, when querying the above tables, by default, the first 1000 (999 for messages
) records are returned.
To retrieve more records, use the LIMIT
clause in your SQL queries. For example:
When using the LIMIT clause to query additional records, you may encounter Slack API rate limits.
Next Steps
Follow this tutorial to build an AI agent with MindsDB.