Integrating WhatsApp into Telegram using the GREEN API#
Want to combine the power of WhatsApp with the convenience of the Telegram platform? It's easy with our greenapi-integration-telegram library!
In this guide, you'll create a Telegram bot that will receive WhatsApp messages and allow you to reply to them without leaving the comfort of your Telegram chat.
Contents#
- Step 1. Preparing WhatsApp via Green-API
- Step 2. Preparing Telegram
- Step 3. Preparing the Local Server
- Step 4. Installing the Integration
- Step 5. Launching the Application
- Step 6. Getting Started
- Conclusion
Step 1. Preparing WhatsApp via Green-API#
To use the GREEN-API application, you need to obtain a registration token and instance ID in your console.
- Log in or register an account with GREEN-API.
-
Create an instance. For testing, we recommend using the free Developer plan.
- In your console, click the
Create instancebutton and select a plan.


- In your console, click the
-
Authorize the instance. To do this:
- Click the
Get QRbutton on the instance setup page. - In the WhatsApp or WhatsApp Business mobile app, sign in to your linked devices and scan the received QR code.

After successful authorization, the instance should receive the 'Authorized' status.
You can check the instance status using theGetStateInstancemethod. - Click the
-
Copy the
idInstanceandapiTokenInstancevalues and save them for integration setup
Step 2. Preparing Telegram#
- Find the official bot channel
@BotFatherwith a blue checkmark in Telegram. - Click the button.
Startor send the/startcommand - Send the
/newbotcommand to create a new bot - Send a name for the bot - this is the name users will see in the chat
- Create and send a nickname, which must be unique and end in bot (e.g.,
telegram_bot) - BotFather will create your bot and send you a message with a token and a link to it
- Save this token for integration setup
Step 3. Preparing the local server#
This step is only for those testing the bot locally.
You'll need this if:
- You're running the bot on your own computer
- You're working from home/office without a public IP
- You want to test webhooks on a local machine
Not needed if:
- The bot is already hosted on a server/VPS
- You have a public IP address
- You're using cloud hosting
-
Go to dashboard.ngrok.com
You'll need to create an account to use the service. -
In the left menu, select Setup & Installation

-
Download the appropriate version for your OS, unzip the archive, and install the contents.

-
On the ngrok website, select Your Authtoken

-
Copy the token shown at the top of the screen.

-
Run the following in the command line:
ngrok config add-authtoken YOUR_AUTH_TOKEN # token obtained from the website -
Run ngrok
ngrok http 3000 -
A session will open for forwarding requests from an external address.
Find the Forwarding line (second from the bottom) and save this address for integration setupForwarding https://your-address.ngrok-free.dev -> http://localhost:3000
Step 4. Installing the Integration#
Clone or create the project:
mkdir greenapi-integration-telegram
Clone the repository:
git clone https://github.com/green-api/greenapi-integration-telegram.git
Install dependencies:
npm install
Configure environment variables in the file .env:
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here # token obtained from BotFather
PORT=3000 # port, default 3000
WEBHOOK_URL= https://your-webhook-url/ # public server address for receiving notifications
Step 5. Launching the application#
The application is launched with the command:
npm start
Step 6 Getting Started#
Start a conversation with the bot:
/start
Connect a Green-API instance to receive messages from WhatsApp:
/instance [idInstance] [apiTokenInstance]
idInstance: ID of your GREEN-API instanceapiTokenInstance: API token of your GREEN-API instance
Example:
/instance 1101111111 abcdef123456789abcdef123456789
Now the bot will receive and send you messages from the WhatsApp account connected to Green-API instance, in a Telegram chat with the bot.
Conclusion#
By following these simple steps, you can create a Telegram bot that will receive WhatsApp messages and allow you to send responses.
GREEN-API is always happy to help you integrate WhatsApp with other platforms.