Telegram bot support [GOT CREATED]

Hi, I think the telegram bot is so important to me.

The bot should have functions to receive messages and send messages.

I hope we can use it later.

I agree too.
I think one of the best use of automation is use for bots.

Please vote to prefer.:sob::sob::sob:

I am actually quite surprised. Bots were not one of the things I did expect people to build with n8n, even though I knew it would theoretically be possible. Simply thought there are already better solutions out there specifically for that.

But great to hear! Happy about any additional use-case. It can only be good for n8n to have more people interested and involved.

As you said, it is possible that there are some solution out there but they don’t think like someone like you:

  • Some of them want to work with thirds Party apps and also target usual users, but they have their servers and you should create your bot there. Most of them are slow, expensive and … But most compatible with bots, like flowxo.com.

  • Some of them has open source platform like you but they have targeted unfortunately just developers like botpress.io

I think developers need less services, they like their pure codes.

But I think you have target all users with various knowledge. You try to use coding and not coding.

About bots and automation:
I think bots can trigger some important workflows and workflows and bot could have close interact together, for example with a bot and workflow a user can get wanted cryptoCurrency price.

Thanks a lot for giving me some background on that!

Will try to find some time the next days to look into a Telegram integration and if it does not look like to much work I will implement it.

1 Like

Dear jan
Do you probably Investigated on telegram integration?

Already wrote it:


Even though it was more work than I hoped it would be.

Will release the new version with Telegram-Integration in the next hours.

The new version with Telegram support is published as [email protected]

Here a very basic bot which simply returns the ID of a sticker:

{
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ]
      },
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1,
      "position": [
        450,
        300
      ],
      "credentials": {
        "telegramApi": ""
      }
    },
    {
      "parameters": {
        "chatId": "={{$node[\"Look for Sticker\"].data[\"message\"][\"chat\"][\"id\"]}}",
        "text": "=Hi {{$node[\"Look for Sticker\"].data[\"message\"][\"from\"][\"first_name\"]}}!\nThe ID of the sticker is: {{$node[\"Look for Sticker\"].data[\"message\"][\"sticker\"][\"file_id\"]}}\nIt is part of the sticker-set: {{$node[\"Look for Sticker\"].data[\"message\"][\"sticker\"][\"set_name\"]}}",
        "additionalFields": {}
      },
      "name": "Return Sticker",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        850,
        200
      ],
      "credentials": {
        "telegramApi": ""
      }
    },
    {
      "parameters": {
        "chatId": "={{$node[\"Look for Sticker\"].data[\"message\"][\"chat\"][\"id\"]}}",
        "text": "=Hi {{$node[\"Look for Sticker\"].data[\"message\"][\"from\"][\"first_name\"]}}!\nYour message did not contain any sticker.",
        "additionalFields": {}
      },
      "name": "Return no Sticker found",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        850,
        400
      ],
      "credentials": {
        "telegramApi": "n8nTestBot"
      }
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{!!$node[\"Telegram Trigger\"].data[\"message\"][\"sticker\"]}}",
              "value2": true
            }
          ]
        }
      },
      "name": "Look for Sticker",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    }
  ],
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Look for Sticker",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Look for Sticker": {
      "main": [
        [
          {
            "node": "Return Sticker",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Return no Sticker found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Added the above example workflow now also to the workflow database on n8n.io:
https://n8n.io/workflows/27

Dear jan
This is very big great job.
I’m so excited for use this node on my workflows

Really great to hear!

I hope it does everything you need. If any functionality is missing which is important to me comment here then I can try to get it added with the next version.

The wired thing is that:
In telegram trigger, I set a token in telegram api that I get from making new bot in botfather.
When I save my workflow and want to active the flow it show below error:

Problem

There was a problem and the workflow could not be activated:
The node of type “n8n-nodes-base.telegramTrigger” does not have access to credentials “Myn8ntestbot” of type “telegramApi”.

Ah yes you have to give the node the right to access the credentials. I guess you created them out of the “Telegram” node. So only that node does have access to it right now.

To also give the “Telegram Trigger” node access go in the credentials and underneath the token there are two boxes. In the left one you should see the “Telegram Trigger” node and in the right one the “Telegram” node. Select the “Telegram Trigger” node and then press the right-arrow-button in the middle. You should then see both nodes in the right box. Press then save and everything should work fine.

I’m So stupid.
Thanks

Another thing please:

  • Sometimes I send a message to my users in telegram that have “reply keyboard” and they select one of that buttons. How can I get that replies in my flow?:face_with_monocle::face_with_monocle::face_with_monocle:

The trigger node can listen to different updates. By default it listens to all. So it will trigger already on that reply. If you want that it triggers different nodes, you can simply create create two different nodes:

  • One that listens to only “message” to get triggered everytime you get a message
  • One that listens to only “callback_query” to get triggered everytime you get a callback response

Actually was a mistake that it listed by default to “all”. It should by default be empty and the user has to select what to listen to. I fixed that and released a new version.

1 Like

I will try it now.
Thanks man.

No problem. Did also work with the old version but in the new version it forces the user to decide what to listen to and that will make it clearer. Listening by default to everything could cause some issues if people leave it like that and do not think about it anymore.

1 Like

Another thing please:
When I send a message with"reply keyboard" to a user on telegram, my flow should be pause and should be waiting for user reply, but now if I use two node continually, the first message will be missed for reply.

I thing when a message have reply keyboard or inline keyboard, the flow should be pause and will be waiting for user reply, isn’t it?