Skip to content

Setting up n8n and Telegram integration#

The GREEN-API platform has its own app on the n8n service. We currently recommend using a local installation of n8n.

Integration setup procedure:

  1. Installing nodejs
  2. Installing ngrok
  3. Creating an instance in GREEN-API
  4. Installing the GREEN-API community node
  5. Examples of using the GREEN-API application

1. Installing nodejs#

  1. Download and install Node.js LTS
  2. Verify successful installation by typing node -v in the command line
  3. Install n8n by typing npm install n8n -g in the command line
  4. Run n8n by typing n8n in the command line
  5. The console will be accessible at http://localhost:5678

2. Installing ngrok#

For the webhook server to work, it must be accessible from the outside. To do this, install ngrok or an equivalent.

  1. Download and install ngrok
  2. Run ngrok – in the command line, type ngrok http 5678
  3. The network server address will be obtained. Pass it to n8n via the WEBHOOK_URL environment variable and start n8n:

    • In the Command Prompt (cmd): set WEBHOOK_URL={received address}&& n8n start
    • In PowerShell: $env:WEBHOOK_URL="{received address}"; n8n start
    • If you run n8n with Docker or Docker Compose, you can set the WEBHOOK_URL={received address} parameter in the .env file

    Start n8n in the same terminal window where the WEBHOOK_URL variable is set — the variable does not apply in other windows.

3. Creating an instance in GREEN-API#

To use the GREEN-API application, you need to obtain a registration token and instance ID in console. For testing, we recommend using the free developer plan.

  1. Log in or register for an account with GREEN-API
  2. Create a Telegram instance on the free "Developer" plan. To do this, in console, click the Create instance button and select a plan

    create-instance

    developer

  3. Authorize the instance. To do this:

    • You can scan the QR code on the instance setup page.
      In the Telegram mobile app, open the Devices section and scan the QR code received by clicking the Get QR button.

      scan-qr

    • Or authorize by authorization code. Request the code using the StartAuthorization method — the code will arrive in the Telegram service chat or by SMS. Send the received code using the SendAuthorizationCode method. If your account is protected by a password, also specify it in the password field.

      code

    We recommend authorizing by QR code. Learn more about authorization methods in the Before you start section

    After successful authorization, the instance should receive the Authorized status. You can check the instance status using the method GetStateInstance

  4. Copy the idInstance and apiTokenInstance values for further use with n8n

    console

4. Installing the GREEN-API community node#

Go to the n8n page at http://localhost:5678.

  • In the lower-left corner, click Settings and select Community nodes (the Integrations section) in the menu that opens.

    go-to-scenarios

  • Click the Install a community node button.

    go-to-scenarios

  • In the npm Package Name field, enter @green-api/n8n-nodes-telegram-greenapi.

  • Check I understand the risks of installing unverified code from a public source and click the Install button.

    go-to-scenarios


Examples of using the GREEN-API application#

How to Create a Telegram Echo Bot Using the GREEN-API in n8n