---
title: Chatbot
sidebarTitle: Chatbot
---

Within MindsDB, chatbots are [agents](/mindsdb_sql/agents/agent) connected to a chat interface.

Creating a chatbot requires either an [AI agent](/mindsdb_sql/agents/agent) or an LLM, and a connection to a chat app, like [Slack](/integrations/app-integrations/slack) or [MS Teams](/integrations/app-integrations/microsoft-teams).

<p align="center">
  <img src="/assets/chatbot_diagram.png" />
</p>

## `CREATE CHATBOT` Syntax

Here is how to create a chatbot that integrates an AI Agent and can be connected to a chat interface.

```sql
CREATE CHATBOT my_chatbot
USING
    database = 'my_slack',   -- created with CREATE DATABASE my_slack
    agent = 'my_agent',   -- created with CREATE AGENT my_agent
    is_running = true;   -- default is true
```

It creates a chatbot that users can interact with via the configured chat interface.

View all chatbots with this command.

```sql
SHOW CHATBOTS;
```

### `database`

In MindsDB, the [`CREATE DATABASE` command](/mindsdb_sql/sql/create/database) is used to connect data integrations including databases and applications such as chat interfaces.

The `database` parameter stores the name of the chat interface connected to MindsDB with the [`CREATE DATABASE` command](/mindsdb_sql/sql/create/database), such as [Slack](/integrations/app-integrations/slack) or [MS Teams](/integrations/app-integrations/microsoft-teams).

### `agent`

The `agent` parameter stores the name of the agent created in MindsDB with the [`CREATE AGENT` command](/mindsdb_sql/agents/agent).

Alternatively, user can use the `model` parameter, instead of `agent`, to connect an LLM created in MindsDB with the [`CREATE MODEL` command](/mindsdb_sql/sql/create/model).

### `is_running`

The `is_running` parameter defines whether the chatbot is going to be available right after its creation (`true`) or not (`false`).

If it is set to `false`, users can enable it with this command.

```sql
UPDATE CHATBOT my_chatbot
SET
  is_running = true;
```

<Tip>
Here are some tips for using the Slack integration:

1. If you want to use Slack in the [`CREATE CHATBOT`](/agents/chatbot) syntax, use [this method of connecting Slack to MindsDB](/integrations/app-integrations/slack#method-1-chatbot-responds-in-direct-messages-to-a-slack-app).

2. If you want 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*.
</Tip>

## `DROP CHATBOT` Syntax

Here is how to delete a chatbot:

```sql
DROP CHATBOT my_chatbot;
```

## Example

Following the example from [here](/agents/agent#example), let's create a chatbot utilizing the already created agent.

Start by connecting a chat app to MindsDB:

* Follow [this instruction](/integrations/app-integrations/slack) to connect Slack to MindsDB.
* Follow [this instruction](/integrations/app-integrations/microsoft-teams) to connect MS Teams to MindsDB.

Next, create a chatbot.

```sql
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;
```

<Tip>
Follow [this tutorial](/use-cases/ai_agents/build_ai_agents) to build your own chatbot.
</Tip>
