> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chatbotplatform.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Building a Basic Support Bot

> Step-by-step guide to creating your first AI-powered customer support chatbot

Learn how to build a functional customer support bot from scratch. This beginner-friendly guide walks you through creating a bot, connecting it to Telegram, and setting up an AI integration.

## What You'll Learn

By the end of this guide, you'll have:

* A working support bot deployed to Telegram
* An AI integration that handles customer questions
* Typing indicators for natural conversations
* Automatic conversation history tracking
* Basic understanding of bot configuration

## Prerequisites

Before starting, you'll need:

* A Chatbot Platform account ([sign up here](https://app.chatbotplatform.io/register))
* A Telegram account
* An API key from OpenAI, Anthropic, or another AI provider
* 15 minutes of your time

## Step 1: Create Your Bot

**1. Access the Dashboard**

Log into [Chatbot Platform](https://app.chatbotplatform.io) and navigate to the Bots page.

**2. Click Create Bot**

Click the **Create Bot** button in the top right corner.

![Bots dashboard](https://mintlify.s3.us-west-1.amazonaws.com/chatbotplatform/images/screenshots/01-getting-started/01_bots_index.png)

Bots dashboard

**3. Fill in Bot Details**

Enter the following information:

* **Name**: "Support Bot" (or your preferred name)
* **Description**: "Customer support assistant that answers common questions"

![Create bot form](https://mintcdn.com/chatbotplatform/QhGUbEN05MzAjt2K/images/screenshots/01-getting-started/03_create_bot_form.png?fit=max\&auto=format\&n=QhGUbEN05MzAjt2K\&q=85\&s=0d7a8d37b31f44d34d8a24661a1763c9)

Create bot form

**4. Create the Bot**

Click **Create** to generate your bot instance.

Your bot is now created! Next, we'll connect it to Telegram so users can interact with it.

## Step 2: Connect to Telegram

**1. Open BotFather on Telegram**

In Telegram, search for [@BotFather](https://t.me/BotFather) and start a chat.

**2. Create a New Telegram Bot**

Send the command `/newbot` to BotFather.

Follow the prompts:

* **Name**: "My Support Bot" (display name, can be anything)
* **Username**: "my\_support\_bot" (must be unique and end with "bot")

**3. Copy the Bot Token**

BotFather will provide a token that looks like:

```
123456789:ABCdefGHIjklMNOpqrsTUVwxyz
```

Copy this token - you'll need it in the next step.

**4. Add Telegram Channel**

Back in Chatbot Platform:

1. Go to your bot's page
2. Click the **Channels** tab
3. Click **Create Channel**
4. Select **Telegram**
5. Paste your bot token
6. Click **Create**

![Telegram channel form](https://mintlify.s3.us-west-1.amazonaws.com/chatbotplatform/images/screenshots/03-channels/01_telegram_form.png)

Channel configuration

**5. Verify Connection**

The platform automatically configures the webhook. Your bot is now listening for messages on Telegram.

Keep your bot token secret. Never share it publicly or commit it to version control.

## Step 3: Set Up AI Integration

Now we'll connect your bot to an AI provider so it can generate intelligent responses.

**1. Navigate to Integrations**

From your bot's page, click the **Integrations** tab.

**2. Create Integration**

Click **Create Integration** and enter:

* **Name**: "OpenAI GPT-4"
* **Webhook URL**: Your AI service endpoint (see examples below)
* **Timeout**: 30 seconds
* **Weight**: 100 (use this integration 100% of the time)

![Integration configuration](https://mintcdn.com/chatbotplatform/IwOyuSig9ydzaHpG/images/screenshots/02-integrations/03_integration_basic_info.png?fit=max\&auto=format\&n=IwOyuSig9ydzaHpG\&q=85\&s=fe9bedac25887b9547a1faf26518a754)

Integration setup

**3. Add Authentication Headers**

Add the required authentication headers for your AI provider:

For OpenAI:

```
Authorization: Bearer sk-proj-YOUR_API_KEY
Content-Type: application/json
```

For Anthropic:

```
x-api-key: sk-ant-YOUR_API_KEY
anthropic-version: 2023-06-01
Content-Type: application/json
```

**4. Save Integration**

Click **Create** to save the integration.

Most AI providers require a proxy service to transform the payload format. See the [Webhook Integration Guide](https://docs.chatbotplatform.io/guides/webhook-integration-guide.md) for detailed setup instructions.

## Step 4: Configure Bot Behavior

Customize how your bot behaves in conversations.

**1. Go to Behavior Settings**

Click the **Behavior** tab on your bot's page.

**2. Enable Typing Indicators**

Turn on **Typing Indicators** to show a typing animation while the bot processes responses.

This makes conversations feel more natural and gives users feedback that their message is being handled.

**3. Set Reply Detection**

For group chats, configure when the bot should respond:

* **All Messages**: Respond to every message (good for support channels)
* **Mentions Only**: Only respond when @mentioned
* **Thread Replies**: Only respond in threads where bot is active

**4. Set Context Window**

Set the conversation context window to **10-15 messages**.

This determines how much conversation history is sent to your AI integration.

## Step 5: Test Your Bot

**1. Open Telegram**

Find your bot in Telegram by searching for its username.

**2. Start a Conversation**

Click **Start** or send `/start` to begin.

**3. Send a Test Message**

Try asking a common support question:

```
What are your business hours?
```

**4. Verify Response**

The bot should:

1. Show a typing indicator
2. Process your message through the AI integration
3. Reply with an intelligent response

Congratulations! Your support bot is now live and responding to messages.

## Testing Your Bot

### Example Conversation

Here's what a typical interaction looks like:

```
User: Hi, I need help with my order

Bot: [typing indicator appears]

Bot: Hello! I'd be happy to help you with your order.
Could you please provide your order number or the email
address you used when placing the order?

User: Order #12345

Bot: [typing indicator appears]

Bot: Thank you! Let me look up order #12345 for you...
```

### What to Test

Test these common scenarios:

1. **Basic Questions**: Ask simple questions your bot should know
2. **Follow-up Questions**: Test if conversation context is maintained
3. **Group Behavior**: Add bot to a group and test mention detection
4. **Response Time**: Verify typing indicators appear and responses are timely
5. **Error Handling**: Send unexpected input to see how the bot handles it

## Improving Your Bot

### Write a Better System Prompt

The system prompt defines your bot's personality and capabilities. Here's a template:

```
You are a helpful customer support assistant for [Your Company Name].

Your role is to:
- Answer customer questions clearly and professionally
- Provide information about products, services, and policies
- Help troubleshoot common issues
- Escalate complex problems to human agents when necessary

Guidelines:
- Always greet customers warmly
- Keep responses concise (2-3 sentences when possible)
- Use bullet points for lists
- If you don't know something, admit it honestly
- Never make up information
- Maintain a friendly, professional tone

When to escalate:
- Requests for refunds or account changes
- Technical issues you cannot resolve
- Customer expresses frustration or requests human agent
```

### Add Knowledge Base Context

To provide accurate answers, include your documentation in the AI context:

**Option 1: RAG (Recommended)**

* Embed your documentation in a vector database
* Search for relevant articles based on user questions
* Include relevant content in the AI prompt

**Option 2: Static Context**

* Include key information directly in the system prompt
* Best for small knowledge bases (\< 5 pages)
* Update prompt when documentation changes

### Monitor Conversations

Regularly review conversations to identify:

* Questions the bot handles well
* Topics that need better answers
* Common confusion points
* Opportunities for improvement

## API Examples

You can also interact with your bot programmatically via the API.

> [accordion] Send a message to a user
>
> > [tab] cURL
> >
> > ```bash theme={null}
> > curl -X POST https://api.chatbotplatform.io/v1/messages \
> >   -H "Authorization: Bearer YOUR_API_KEY" \
> >   -H "Content-Type: application/json" \
> >   -d '{
> >     "bot_id": "bot_123",
> >     "channel_type": "telegram",
> >     "chat_id": "987654321",
> >     "message": "Hello from the API!"
> >   }'
> > ```
>
> > [tab] JavaScript
> >
> > ```javascript theme={null}
> > const response = await fetch('https://api.chatbotplatform.io/v1/messages', {
> >   method: 'POST',
> >   headers: {
> >     'Authorization': 'Bearer YOUR_API_KEY',
> >     'Content-Type': 'application/json'
> >   },
> >   body: JSON.stringify({
> >     bot_id: 'bot_123',
> >     channel_type: 'telegram',
> >     chat_id: '987654321',
> >     message: 'Hello from the API!'
> >   })
> > });
> >
> > const data = await response.json();
> > console.log('Message sent:', data);
> > ```
>
> > [tab] PHP
> >
> > ```php theme={null}
> > use Illuminate\Support\Facades\Http;
> >
> > $response = Http::withToken('YOUR_API_KEY')
> >     ->post('https://api.chatbotplatform.io/v1/messages', [
> >         'bot_id' => 'bot_123',
> >         'channel_type' => 'telegram',
> >         'chat_id' => '987654321',
> >         'message' => 'Hello from the API!'
> >     ]);
> >
> > $data = $response->json();
> > ```
>
> > [tab] Python
> >
> > ```python theme={null}
> > import requests
> >
> > response = requests.post(
> >     'https://api.chatbotplatform.io/v1/messages',
> >     headers={'Authorization': 'Bearer YOUR_API_KEY'},
> >     json={
> >         'bot_id': 'bot_123',
> >         'channel_type': 'telegram',
> >         'chat_id': '987654321',
> >         'message': 'Hello from the API!'
> >     }
> > )
> >
> > data = response.json()
> > print('Message sent:', data)
> > ```

> [accordion] Get conversation history
>
> > [tab] cURL
> >
> > ```bash theme={null}
> > curl https://api.chatbotplatform.io/v1/conversations/conv_123/messages \
> >   -H "Authorization: Bearer YOUR_API_KEY"
> > ```
>
> > [tab] JavaScript
> >
> > ```javascript theme={null}
> > const response = await fetch(
> >   'https://api.chatbotplatform.io/v1/conversations/conv_123/messages',
> >   {
> >     headers: {
> >       'Authorization': 'Bearer YOUR_API_KEY'
> >     }
> >   }
> > );
> >
> > const messages = await response.json();
> > ```
>
> > [tab] PHP
> >
> > ```php theme={null}
> > $messages = Http::withToken('YOUR_API_KEY')
> >     ->get('https://api.chatbotplatform.io/v1/conversations/conv_123/messages')
> >     ->json();
> > ```
>
> > [tab] Python
> >
> > ```python theme={null}
> > response = requests.get(
> >     'https://api.chatbotplatform.io/v1/conversations/conv_123/messages',
> >     headers={'Authorization': 'Bearer YOUR_API_KEY'}
> > )
> >
> > messages = response.json()
> > ```

For complete API documentation, see the [OpenAPI specification](https://app.chatbotplatform.io/openapi).

## Common Issues

### Bot doesn't respond

**Possible causes:**

* Integration webhook URL is incorrect
* Authentication headers are missing or invalid
* Integration timeout is too short
* AI service is down or rate-limited

**Solutions:**

* Test the integration using the built-in test feature
* Verify API keys are correct and have proper permissions
* Check integration logs for error messages
* Increase timeout if responses take longer than expected

### Bot responds to every message in group chat

**Cause:** Reply detection is set to "All Messages"

**Solution:** Change to "Mentions Only" or "Thread Replies" in Behavior settings

### Typing indicator doesn't appear

**Cause:** Typing indicators are disabled or channel doesn't support them

**Solution:** Enable typing indicators in Behavior settings. Note that not all channels support this feature.

### Responses are slow

**Possible causes:**

* AI model is slow (e.g., GPT-4 vs GPT-3.5)
* Network latency between platform and your integration
* Your integration is processing additional logic

**Solutions:**

* Use a faster AI model
* Optimize your integration code
* Increase timeout to allow more processing time

## Next Steps

> [card] [Add Grounded Responses](https://docs.chatbotplatform.io/guides/grounded-support-bot.md)
>
> Use Agentic Loops to ground responses in real data

> [card] [Deploy to More Channels](https://docs.chatbotplatform.io/guides/multi-channel-deployment.md)
>
> Connect your bot to Slack, Discord, and more

> [card] [Manage Conversation Context](https://docs.chatbotplatform.io/guides/conversation-context.md)
>
> Control how conversation history is handled

> [card] [Webhook Integration Deep Dive](https://docs.chatbotplatform.io/guides/webhook-integration-guide.md)
>
> Learn advanced integration patterns

## Related Documentation

* [Bot Behaviors](https://docs.chatbotplatform.io/bots/behaviors/index.md) - Configure typing indicators and reply detection
* [Telegram Channel](https://docs.chatbotplatform.io/bots/channels/telegram.md) - Telegram-specific features and settings
* [Webhook Setup](https://docs.chatbotplatform.io/bots/integrations/webhook-setup) - Detailed integration configuration
* [API Reference](https://app.chatbotplatform.io/openapi) - Complete API documentation


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.