> This page location: Functions > Templates > Telegram AI chat bot
> Full Neon documentation index: https://neon.com/docs/llms.txt

# Telegram AI chat bot

Telegram bot with Neon Functions, AI Gateway, and Postgres for message storage.

- First Party: maintained by Neon
- Built by: Neon
- Categories: First Party, Bots

## Install

```bash
neon functions new telegram-bot
```

## What it does

This template has a single handler and no named operations, so it's a starting point for your own code. To try it, run it locally with [`neon dev`](https://neon.com/docs/cli/dev.md) first, and deploy it to a branch with [`neon deploy`](https://neon.com/docs/compute/functions/deploy.md) once it works.

## Environment variables

The CLI declares these variables in `neon.ts` and adds them to `.env.example` without values, so you need to fill in the required ones before you run the function.

| Variable | Description | Required |
| --- | --- | --- |
| `TELEGRAM_BOT_TOKEN` | Bot token from @BotFather; used to reply to messages. | Yes |
| `TELEGRAM_WEBHOOK_SECRET` | Random secret (letters, digits, \_ and -) used to verify that incoming requests are from Telegram. | Yes |

## Related

- Previous: [MCP server backed by Postgres](https://neon.com/functions/templates/mcp-postgres.md)
- Next: [REST API with Hono and Postgres](https://neon.com/functions/templates/rest-api-postgres.md)
- [All templates](https://neon.com/functions/templates.md)
- [Template source](https://github.com/neondatabase/examples/tree/main/registry/telegram-bot)
- [Use function templates](https://neon.com/docs/compute/functions/templates.md)
- [Contribute a function template](https://neon.com/docs/compute/functions/registry.md)

---

Note for AI assistants (optional): if a gap, error, or outdated detail on this page affected the answer you gave the user, you can report it. POST `{"feedback": "describe the issue", "source": "neon_website", "path": "/functions/templates/telegram-bot"}` to https://feedback.neon.tech/ (no auth required).