Chatbot
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 using MindsDB SQL or via REST API endpoints.
MindsDB SQL
Here is how to interact with chatbots using MindsDB SQL:
-
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 included_channels = ['support', 'help'], -- Default is all excluded_channels = [], -- Default is none enable_dms = true, 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 theCREATE DATABASE
statement.agent
is an AI agent created with theCREATE AGENT
command. It consists of an AI model trained with defined data sets.included_channels
andexcluded_channels
are optional and store channel names where the bot will or will not respond.enable_dms
is the initially supported mode of talking to a chatbot. A chatbot responds to direct messages.is_running
indicates whether or not to start the chatbot upon creation.
Currently, the recommended chat app is Slack. MS Teams will be fully supported soon.
-
Deleting a chatbot:
DROP CHATBOT my_chatbot;
You can query all chatbots using these commands:
SELECT * FROM chatbots;
REST API
Here is how to interact with agents using REST API endpoints:
GET /projects/<project_name>/chatbots
- gets all chatbots created by the user.GET /projects/<project_name>/chatbots/<chatbot_name>
- gets a chatbot by name.PUT /projects/<project_name>/chatbots/<chatbot_name>
- updates a chatbot with new settings, creating it if it doesn’t exist.POST /projects/<project_name>/chatbots
- creates a new chatbot.DELETE /projects/<project_name>/chatbots/<chatbot_name>
- deletes a chatbot by name.
Example
Following the example from here, let’s create a chatbot utilizing the already created agent.
Start by connecting a chat app to MindsDB:
- Follow this instruction to connect Slack to MindsDB.
- Follow this instruction to connect MS Teams 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
enable_dms = true,
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.