Within MindsDB, chatbots are agents connected to some messaging interface.

Creating a chatbot requires an AI agent and a connection to a chat app, like Slack or MS Teams.

Currently, the recommended chat app is Slack. MS Teams will be fully supported soon.

How to work with chatbots

A chatbot can be created, deleted, queried, and updated. Here is how you can do that using SQL API.

  • Creating a chatbot:

    CREATE CHATBOT my_chatbot
    USING
        database = 'my_slack',                    -- this must be created with CREATE DATABASE
        agent = 'customer_support_agent',         -- this must be created with CREATE AGENT
        is_running = true;                        -- default is true
    

    The parameters include the following:

    • database stores connection to a chat app (like Slack or MS Teams) that should be created with the CREATE DATABASE statement.
    • agent is an AI agent created with the CREATE AGENT command. It consists of an AI model trained with defined data sets.
    • is_running indicates whether or not to start the chatbot upon creation.

    If you want to use Slack in the CREATE CHATBOT syntax, use this method of connecting Slack to MindsDB.

    How to connect the chatbot to multiple Slack channels?

    Open your Slack application and add the App/Bot to one or more channels:

    • 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.
  • Deleting a chatbot:

    DROP CHATBOT my_chatbot;
    

You can query all chatbots using these commands:

SHOW CHATBOTS;

SELECT * FROM chatbots;

Example

Following the example from here, let’s create a chatbot utilizing the already created agent.

Start by connecting a chat app to MindsDB:

Next, create a chatbot.

CREATE CHATBOT text_to_sql_chatbot
USING
    database = 'my_slack',        -- this must be created with CREATE DATABASE
    agent = 'text_to_sql_agent',  -- this must be created with CREATE AGENT
    is_running = true;

To create my_slack and be able to talk to the chatbot via DMs, follow this instruction.

To see how the agent is created, follow this example.