An open-source RAG bot for Slack and Discord using Vectara. With this bot you can create a Slack or Discord bot that is connected to your server and answers user questions by querying a Vectara corpus.
- Mention the bot in a message to receive a reply.
- Send a direct message to the bot for a 1:1 conversation.
- The bot stores message and thread IDs to provide context-aware replies in threads or while replying.
- Mention the bot:
@bot-name Your message here
- Send a direct message:
Your message here
- Python 3.8 or higher
- Clone the repository:
git clone https://github.com/vectara/ragtime.git cd ragtime
- Install the required dependencies:
pip3 install requirement.txt
- Set Up Environment Variables:
- Create a
.env
file in the root of your project and add the following:
SLACK_BOT_TOKEN=<OAuth level token> SLACK_APP_TOKEN=<APP level token> DISCORD_BOT_TOKEN=<Discord bot token> VECTARA_CUSTOMER_ID="<VECTARA_CUSTOMER_ID>" VECTARA_CORPUS_IDS="<VECTARA_CORPUS_IDS>" VECTARA_API_KEY="<VECTARA_API_KEY>" ACCOUNT_SID=<Twilio account SID> Auth_TOKEN=<Twilio auth token> TWILIO_WHATSAPP_NUMBER=<Whatsapp number configured in twilio>
To enable agentic rag add the following variables.
ENABLE_AGENTIC_RAG=True ## To enable agentic rag. By default ragtime uses vanilla RAG. AGENTIC_RAG_DATA_DESCRIPTION='Vectara website, docs and forum data' AGENTIC_RAG_ASSISTANT_SPECIALTY='Vectara' AGENTIC_RAG_TOOL_NAME='ask_vectara'
- The
VECTARA_CUSTOMER_ID
andVECTARA_CORPUS_IDS
point to your Vectara account and relevant corpora to use. VECTARA_CORPUS_IDS
can be a single corpus ID (numeric) or a comma-separated list of corpora.
- Create a
RagTime supports Slack bot, Discord bot and Whatsapp bot. You can run one of these, or all.
-
python3 main.py
-
python3 main.py slack
-
python3 main.py discord
-
python3 main.py whatsapp
Build and Run with docker.
-
bash run_docker.sh
-
bash run_docker.sh slack
-
bash run_docker.sh discord
-
bash run_docker.sh whatsapp
In orer to connect your ragtime bot to your Slack service, follow these steps:
- Log in to your Slack workspace and navigate to the Slack API website. Click on "Your Apps" and then "Create New App." Provide a name for your app, select the workspace where you want to install it, and click "Create App."
- In the app settings, you can configure various details such as the app name, icon, and description. Make sure to fill out the necessary information accurately.
- Once you've configured your app, navigate to the "Install App" section. Click on the "Install App to Workspace" button to add the bot to your Slack workspace. This step will generate an OAuth access token that you'll need to use to authenticate your bot.
- To add user token scope, navigate to the "OAuth & Permissions" section in your app settings. Under the "OAuth Tokens for Your Workspace" section, you'll need to add
app_mentions:read
,channels:history
,chat:write
,chat:write.public
,groups:history
,im:history
,mpim:history
,mpim:read
,mpim:write
,users:read
scopes. Create the token and save it asSLACK_BOT_TOKEN
in your.env
file. - Create an app level token with the
connection:write
scope. Save this token asSLACK_APP_TOKEN
in your.env
file. - Make sure to save any changes you've made to your app settings and install/reinstall the bot to workplace.
In order to connect your ragtime bot to your Discord server, follow these steps:
- Navigate to Discord Developer Portal Applications Page and create a new application by clicking on the ‘New Application‘ button on the top-right corner.
- Go to the ‘Bot‘ page by selecting the ‘Bot‘ option from the left column.
- Copy the provided token and save it as
DISCORD_BOT_TOKEN
. - Choose ‘OAuth2’ from the left column and select the URL Generator.
- In the ‘Bot Permissions’ section at the bottom, select the necessary permissions.
- Choose the ‘bot’ option in the ‘Scope’ box, and the ‘BOT PERMISSIONS’ box will appear below it.
- Select ‘Read Message’, ‘Send Message’, and ‘Manage Message’ options.
- Copy the generated URL and paste it into your web browser. It will redirect you to the Discord page to add the bot to your server.
In order to connect your ragtime whatsapp bot, follow these steps:
- Sign in to your twilio console.
- Navigate to the WhatsApp sandbox.
- Configure the
/whatsapp
endpoint for communication. - Copy the Account SID, Auth Token, and WhatsApp Sandbox Number into
.env
👤 Vectara
- Website: https://vectara.com
- Twitter: @vectara
- GitHub: @vectara
- LinkedIn: @vectara
- Discord: @vectara
Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.
Give a ⭐️ if this project helped you!
Copyright © 2024 Vectara.
This project is Apache 2.0 licensed.