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

# Telegram Setup

> Create and configure your Telegram bot for messaging

This guide walks you through creating a Telegram bot and connecting it to Zavu.

## Step 1: Create a Bot with BotFather

1. Open Telegram and search for [@BotFather](https://t.me/BotFather)
2. Start a conversation and send `/newbot`
3. Follow the prompts to name your bot
4. BotFather will give you a **bot token** like:
   ```
   123456789:ABCdefGHIjklMNOpqrsTUVwxyz
   ```

<Warning>
  Keep your bot token secret. Anyone with this token can control your bot.
</Warning>

## Step 2: Configure in Zavu Dashboard

1. Go to **Senders** in your Zavu dashboard
2. Select your sender or create a new one
3. In the **Channels** tab, click **Add Telegram**
4. Paste your bot token
5. Click **Verify** to confirm the bot is valid
6. Click **Save** to complete setup

## Step 3: Set Up Webhook (Automatic)

When you save your Telegram configuration, Zavu automatically:

* Registers your webhook URL with Telegram
* Starts receiving messages from your bot

No manual webhook configuration is needed.

## Bot Commands (Optional)

You can configure bot commands via BotFather:

```
/setcommands
```

Then send a list of commands:

```
start - Start the conversation
help - Get help information
```

## Testing Your Bot

Once configured, test your bot:

1. Find your bot on Telegram by username
2. Send a message to the bot
3. Check your Zavu Inbox for the inbound message
4. Reply from the Inbox or use the API

<CodeGroup>
  ```typescript TypeScript theme={null}
  const result = await zavu.messages.send({
    to: "123456789", // Chat ID from inbound message
    text: "Thanks for reaching out!",
    channel: "telegram",
  });
  ```

  ```python Python theme={null}
  result = zavu.messages.send(
      to="123456789",  # Chat ID from inbound message
      text="Thanks for reaching out!",
      channel="telegram"
  )
  ```

  ```ruby Ruby theme={null}
  result = client.messages.send(
    to: "123456789", # Chat ID from inbound message
    text: "Thanks for reaching out!",
    channel: "telegram"
  )
  ```

  ```go Go theme={null}
  result, _ := client.Messages.Send(context.TODO(), zavudev.MessageSendParams{
  	To:      zavudev.String("123456789"), // Chat ID from inbound message
  	Text:    zavudev.String("Thanks for reaching out!"),
  	Channel: zavudev.String("telegram"),
  })
  ```

  ```php PHP theme={null}
  $result = $client->messages->send([
      'to' => '123456789', // Chat ID from inbound message
      'text' => 'Thanks for reaching out!',
      'channel' => 'telegram',
  ]);
  ```
</CodeGroup>

## Getting Chat IDs

Telegram chat IDs are obtained from inbound messages:

1. When a user messages your bot, Zavu receives the message
2. The `from` field contains the user's chat ID
3. Store this ID to send future messages

<Note>
  Chat IDs are numeric (e.g., `123456789`). They are different from phone numbers and cannot be derived from them.
</Note>

## Bot Privacy Mode

By default, bots only receive messages that:

* Are sent directly to the bot
* Start with `/` (commands) in groups
* Mention the bot in groups

To receive all messages in groups, disable privacy mode via BotFather:

```
/setprivacy
```

## Troubleshooting

### Bot token invalid

* Regenerate the token via BotFather using `/token`
* Make sure you copied the complete token

### Messages not arriving

* Verify the bot is configured correctly in Zavu
* Check that the webhook is registered (automatic on save)
* Ensure the bot hasn't been blocked by the user

### Can't message user

* Users must initiate contact first
* Check if the user blocked the bot
* Verify the chat ID is correct

## Next Steps

* [Telegram Overview](/guides/telegram/overview) - Learn about Telegram capabilities
* [Webhooks](/guides/webhooks) - Configure webhook events
