Have you ever wished you could chat with your company documents or quickly access information from a vast knowledge base? In this guide, we’ll walk through the process of creating a custom knowledge ChatBot in Slack using Berry AI and a simple Python script. This powerful tool can transform how your team accesses and interacts with information, making it easier than ever to find answers and insights.

What We’ll Build

We’re going to create a Slack bot that can answer questions based on a custom knowledge base. This bot will:

  1. Use Berry AI to process and understand your documents
  2. Integrate with Slack for easy communication
  3. Respond to direct messages with relevant information from your knowledge base

Let’s get started!

Step 1: Create Your Custom Knowledge Base with Berry AI

  1. Go to berry.ai and scroll down to the “Build a Demo” section.
  2. Enter your email address and choose to upload a file.
  3. Add a custom prompt to frame the context of your bot (e.g., “You’re a financial advisor and analyst. You analyze documents and can help the user with investments.”)
  4. Click “Build App” and wait for your link to be ready.

Once your app is built, you can test it by chatting with it directly on the Berry AI platform.

Step 2: Set Up Your Slack Bot

  1. Go to api.slack.com and create a new app from scratch.
  2. Give your app a name and select your workspace.
  3. In the “Bot Token Scopes” section, add the following permissions:
    • im:history
    • im:read
    • im:write
  4. Install the app to your workspace and copy the Bot User OAuth Token.

Step 3: Prepare Your Development Environment

We’ll use Replit for this project, as it provides an easy-to-use online development environment.

  1. Fork the provided Replit project (link in description).
  2. Open the forked project in Replit.

Step 4: Configure Your Bot

In the Replit project:

  1. Go to the “Secrets” tab in the left sidebar.
  2. Add the following secrets:
    • SLACK_TOKEN: Your Bot User OAuth Token
    • SIGNING_SECRET: Found in “Basic Information” > “App Credentials”
    • CLIENT_ID: Found in “Basic Information” > “App Credentials”
    • CLIENT_SECRET: Found in “Basic Information” > “App Credentials”
    • API_ENDPOINT: Your Berry AI API endpoint (found in the Berry AI dashboard)

Step 5: Set Up Slack Event Subscriptions

  1. In your Slack app settings, go to “Event Subscriptions” and enable events.
  2. Set the Request URL to https://your-replit-url.repl.co/slack/events.
  3. Subscribe to the message.im bot event.

Step 6: Configure OAuth & Permissions

  1. In “OAuth & Permissions”, add a redirect URL: https://your-replit-url.repl.co/slack/oauth_redirect.
  2. Update the OAUTH_REDIRECT variable in your Replit code with this URL.

Step 7: Run Your Bot

  1. In Replit, click the “Run” button to start your server.
  2. Copy the URL of your running Replit app.
  3. In your browser, go to https://your-replit-url.repl.co/slack/install.
  4. Follow the prompts to install the bot to your Slack workspace.

Step 8: Test Your Bot

  1. In Slack, find your bot in the direct messages.
  2. Send a message to your bot with a question about your uploaded document.
  3. The bot should respond with relevant information from your custom knowledge base.

Customization and Advanced Usage

  • You can update your Berry AI knowledge base at any time by uploading new documents or modifying your prompt.
  • Consider creating different bots for various purposes, such as a company FAQ bot, a product information bot, or a research assistant bot.
  • Experiment with different prompt structures to optimize your bot’s responses for specific use cases.

By following these steps, you’ve created a powerful tool that combines the flexibility of Slack with the intelligence of a custom knowledge base. This can significantly improve information access and productivity within your organization.

Need help with AI-powered automations? Check out Alacranlabs.com for expert assistance in implementing cutting-edge AI solutions for your business.

“`

Leave a Reply

Your email address will not be published. Required fields are marked *

Take your startup to the next level