slack_bot.mdx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. ---
  2. title: '💼 Slack Bot'
  3. ---
  4. ### 🖼️ Template Setup
  5. - Fork [this](https://replit.com/@taranjeetio/EC-Slack-Bot-Template?v=1#README.md) replit template.
  6. - Set your `OPENAI_API_KEY` in Secrets.
  7. - Create a workspace on Slack if you don't have one already by clicking [here](https://slack.com/intl/en-in/).
  8. - Create a new App on your Slack account by going [here](https://api.slack.com/apps).
  9. - Select `From Scratch`, then enter the Bot Name and select your workspace.
  10. - On the `Basic Information` page copy the `Signing Secret` and set it in your secrets as `SLACK_SIGNING_SECRET`.
  11. - On the left Sidebar, go to `OAuth and Permissions` and add the following scopes under `Bot Token Scopes`:
  12. ```text
  13. app_mentions:read
  14. channels:history
  15. channels:read
  16. chat:write
  17. ```
  18. - Now select the option `Install to Workspace` and after it's done, copy the `Bot User OAuth Token` and set it in your secrets as `SLACK_BOT_TOKEN`.
  19. - Start your replit container now by clicking on `Run`.
  20. - On the Slack API website go to `Event Subscriptions` on the left Sidebar and turn on `Enable Events`.
  21. - Copy the generated server URL in replit, append `/chat` at its end and paste it in `Request URL` box.
  22. - After it gets verified, click on `Subscribe to bot events`, add `message.channels` Bot User Event and click on `Save Changes`.
  23. - Now go to your workspace, click on the bot name in the Sidebar and then add the bot to any channel you want.
  24. ### 🚀 Usage Instructions
  25. - Go to the channel where you have added your bot.
  26. - To add data sources to the bot, use the command:
  27. ```text
  28. add <data_type> <url_or_text>
  29. ```
  30. - To ask queries from the bot, use the command:
  31. ```text
  32. query <question>
  33. ```
  34. 🎉 Happy Chatting! 🎉