Need Help Migrating Telegram Lead Collection Bot from SendPulse to n8n for User Input Capture

Describe the problem/error/question

Hi all,

I’m currently using SendPulse to manage a lead collection bot on Telegram, but I’d like to migrate everything over to n8n for greater flexibility and cost efficiency with the self-hosted version. However, I’m running into some configuration issues that I could use a hand with.

Here’s what I’m looking to set up in n8n:

  • A system that can ask users a series of questions via Telegram, read their responses, and save the data to a database (or Google Sheets for simplicity as I learn).
  • Depending on the user’s response, the workflow would continue with the appropriate steps.

I don’t need any AI integration.

So far, I’m (kind of) managing to record responses when users select buttons in closed-answer formats, but I’m struggling when it comes to capturing open-text responses. For example, if the bot requests the user’s address and waits for a response, I can’t seem to handle the wait and that input correctly in n8n. In SendPulse, this kind of flow is very intuitive and straightforward, but I want to make it work in n8n because it seems like a much more flexible and powerful tool.

If anyone has experience setting up something similar or tips on capturing open responses in Telegram with n8n in a simple way, I’d appreciate any guidance. Thanks!

Information on your n8n setup

  • n8n version: 1.64.3
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own, main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu

hello @shuui

to catch a response in group chats, user should reply to bot and then you can grab the reply with Telegram trigger.

In private chats all message will be captured with the trigger (if you have selected the Message listener)

Thanks. I already tried to use the trigger you are mentioning but probably I’m not fully understanding how it works or I am missing something about n8n.

This is an example. As you can see the execution always end at the node “sendmessage: message” and I can’t find a way to trigger “Telegram Trigger1: message” node.

In the “Telegram sendmessage: message” node I ask for the address and I expect the telegram trigger “updates: message” to be triggered when the user write the address

You can’t use two triggers because of Telegram’s limitations.

Trigger acts as a listener for any content received by the bot. In private chats, it means any content that you’ll send to it.

The logic would be as follows:

  1. a user chooses/sends a command to the bot
  2. the trigger gets triggered and you check what is the user input. In your example, the bot asks for the input data
  3. when a user sends the next input (via reply to action or just in the chat) the trigger gets fired again and you have to check the input and do something with it (validate or store it in the sheet)

In more complex scenarios it will look like this

thank you! Now it is more clear.

I’m still not sure how I can properly pass to the trigger what message they are answering to.

Let me give you an example.

A user is asked if they prefer dogs or cats and they have to send a photo of their dog or their cat.

They send the photo, the telegram trigger is activated and I want to send them a different message according to the animal photo that they sent. How can I understand if the photo is coming after the “send a cat photo” telegram message or the other?

I know you said that you don’t need AI integration, but this looks like an Open AI image analysis problem.

You can query AI for the image analysis. And depending on the response switch with an if case to send different responses.

Let me know how you pulled it off.

it depends on the implementation. You can store the last tg message from bot somewhere (in local file or in the google sheets/db) or you can force user to reply on the bot’s message. In that case when user sends a photo via reply, it will contain also the replied text which you may parse to find which one it was.

E.g.

{
  "update_id": 39735057,
  "message": {
    "message_id": 2097,
    "from": {
      "id": 1145874,
      "is_bot": false,
      "first_name": "user Name",
      "last_name": "user FName",
      "username": "nickname",
      "language_code": "en"
    },
    "chat": {
      "id": 123456,
      "first_name": "user Name",
      "last_name": "user FName",
      "username": "nickname",
      "type": "private"
    },
    "date": 1730983777,
    "reply_to_message": {
      "message_id": 1536,
      "from": {
        "id": 14587,
        "is_bot": true,
        "first_name": "my bot",
        "username": "my_bot_nick"
      },
      "chat": {
        "id": 123456,
        "first_name": "user Name",
        "last_name": "user FName",
        "username": "nickname",
        "type": "private"
      },
      "date": 1730391059,
      "text": "Send me a cat's photo as Reply"
    },
    "photo": [
      {
        "file_id": "AgACAgIAAxkBAAIIMWcst2CZs_oy3GpwYi9FUqPLyZPIAALA5DEbQedhSV_lW99RCbSpAQADAgADcwADNgQ",
        "file_unique_id": "AQADwOQxG0HnYUl4",
        "file_size": 1444,
        "width": 90,
        "height": 60
      },
      {
        "file_id": "AgACAgIAAxkBAAIIMWcst2CZs_oy3GpwYi9FUqPLyZPIAALA5DEbQedhSV_lW99RCbSpAQADAgADbQADNgQ",
        "file_unique_id": "AQADwOQxG0HnYUly",
        "file_size": 18271,
        "width": 320,
        "height": 213
      },
      {
        "file_id": "AgACAgIAAxkBAAIIMWcst2CZs_oy3GpwYi9FUqPLyZPIAALA5DEbQedhSV_lW99RCbSpAQADAgADeAADNgQ",
        "file_unique_id": "AQADwOQxG0HnYUl9",
        "file_size": 83454,
        "width": 800,
        "height": 532
      },
      {
        "file_id": "AgACAgIAAxkBAAIIMWcst2CZs_oy3GpwYi9FUqPLyZPIAALA5DEbQedhSV_lW99RCbSpAQADAgADeQADNgQ",
        "file_unique_id": "AQADwOQxG0HnYUl-",
        "file_size": 168629,
        "width": 1280,
        "height": 851
      }
    ]
  }
}

1 Like

Ooo, I see you are not taking the photo as an input.

Then, smart work around to not use AI. :0

Btw, It looks good.