This repository contains the code to run a Flask app that connects Slack with an AI agent from Relevance AI. Follow the instructions below to set up and configure the integration.
Before you begin, make sure you have the following:
- A Slack workspace and a channel where you want to integrate the AI agent.
- A Relevance AI account.
- An existing agent created in Relevance AI.
- Go to Slack API and log in or create an account if you haven't already. Once logged in, navigate to "Your apps."
- Click on "Create New App" and start from scratch. Give your app a name and choose the workspace where you want your app to reside.
- In the left panel, navigate to "OAuth & Permissions."
- Under "Bot Token Scopes," add the following permissions:
- chat:write
- app_mentions:read
- chat:write
- files:read
- Click "Install to Workspace." After your app is installed, a Bot User OAuth Token will be generated. Save this token securely.
- Navigate to "Basic Information" and copy the signing secret. Store this signing secret safely.
- Go to Replit and fork the Python-Whatsapp-Bot-x-Relevance-AI project.
- In your project's secrets, add your Bot Token from Slack as
SLACK_TOKEN
and the Signing Secret asSIGNING_SECRET
. - Run the app. In the web view tab, click "New Tab," and copy the URL of that new tab.
- Return to the Slack API and navigate to "Event Subscriptions." Click "Enable Events."
- Paste the Replit URL into the "Request URL" field, and add
/slack/events
to the URL. - Wait until it's verified.
- Reinstall the app into your Slack workspace.
- Go to Relevance AI and log in to your account.
- Navigate to the "API Keys" tab on the left side of the screen.
- Scroll down and click on "+ Create New Secret Key."
- Copy the region ID, the project ID, and the authentication token. Store them securely.
- Go to your Relevance AI agent and open the conversation panel. In the URL, the second-to-last string is your agent ID. For example:
app.relevanceai.com/agents/xxxx/agent_id/xxxx
. - Return to Replit and paste these four keys into the corresponding fields in the secrets tab.
- Go to your Slack app, and you should see it listed under the "Apps" section on the left side of the screen.
- Integrate your app into your preferred channel.
- When mentioning the app in the channel, it should respond in that thread. Subsequent messages in that thread will continue the conversation with the agent.
- Threads and messages should also be visible in your Relevance AI agent interface.
Enjoy using the Slack to Relevance AI integration!