# Create and Deploy a Telegram Bot with JavaScript

import ChangelogLayout from '@/src/components/Changelog/ChangelogLayout';


This tutorial will guide you through developing a simple Telegram bot from scratch, utilizing the GrammY framework with JavaScript, and deploying it on Zeabur.

## What is the GrammY Framework?

> GrammY - **The Telegram Bot Framework**

![](https://cdn.sanity.io/images/z9meudi7/production/ecc5ffdc4eb23cff07da354e2220fca62ce684ab-1812x1282.png)

Developing Telegram bots with JavaScript offers several options, such as node-telegram-bot-api or GrammY. The first one is Telegram's Node.js SDK, while GrammY is an emerging, mature framework that comes with many pre-packaged functionalities, simplifying our development process.

## What is Zeabur?

[Zeabur](https://zeabur.com) is a deployment service platform that makes it convenient for developers to deploy their services with one click, without worrying about server infrastructure.

To keep a Telegram bot running continuously, we have two options:

- Running it locally, which requires the computer to stay connected and on

- Deploying it to the cloud, completing development and deploying with one click to Zeabur for continuous and stable bot service

## Creating a Bot and Obtaining a Token

The process to create a bot on Telegram is straightforward. Open Telegram, search for **BotFather**. In the chat, follow the guide and send the `/newbot` command to create a bot, then copy its token.

## Project Initialization

### Prerequisites

- Node.js environment installed on your computer

- A package manager like npm/pnpm installed

### Creating a New Project

First, create a new folder to store your bot code. Then, open a terminal in that directory and enter the command `npm init` to generate a default package.json. Next, install the grammy dependency with `npm install grammy`.

Create a bot.js file:

At this point, you can run your bot with the following command:

```bash
node bot.js
```



After running the bot, you can send messages to the bot you just created on Telegram, and it will reply with "Received: + your message content."

## Deploying to Zeabur

After development is complete, you can deploy your bot to the cloud. Zeabur is recommended for easy one-click deployment.

First, visit Zeabur's official website and register a new account using GitHub. After entering the dashboard, click to create a new project and select your preferred region; here, we choose a data center in Hong Kong.

![](https://cdn.sanity.io/images/z9meudi7/production/a130ccbf48b48b25ddf9d44c2c6063ccedb5f78d-3138x1924.png)

After creating the project, click to create a new service on the project page, choose to deploy from a GitHub repository, select the bot repository you just created, and click import. Zeabur will automatically start deploying your bot. Wait about a minute for the deployment to finish, and then you can go back and enjoy chatting with your bot.

![](https://cdn.sanity.io/images/z9meudi7/production/71176c37034b9f4352caeb92d0a174f0345fed81-3138x1924.png)

## Deploying Telegram Bot Templates

If you just want to have a bot that allows you to use ChatGPT or Gemini on Telegram, you can directly deploy a few bots from Zeabur's template market, such as [Gemini-Telegram-Bot](https://zeabur.com/templates/V2870T) or [ChatGPT-Telegram-Bot](https://zeabur.com/templates/R5JY5O). After clicking deploy, Zeabur will automatically create a corresponding repository for you. You only need to enter your bot token and API key during deployment to start using it.

![](https://cdn.sanity.io/images/z9meudi7/production/581a3bb5e62049921cdb416db6f57c3e40903dee-3138x1924.png)
