Capturing multiple user inputs in n8n workflow with WhatsApp API integration

Help needed with n8n and WhatsApp API

I’m working on an n8n workflow that uses the Meta WhatsApp API. My setup works fine for the first user input, but I’m stuck on how to get the second response.

Here’s what I’ve got so far:

  1. User sends a WhatsApp message
  2. Webhook gets the message
  3. Code node cleans up the data
  4. Switch node decides what to do based on user’s choice
  5. WhatsApp sends more options

The problem is, I can’t figure out how to grab that second user response. I’ve tried a few things:

  • Adding another webhook (didn’t work)
  • Looking into HTTPS stuff in the Meta API docs (only found ways to send messages)
  • Trying to chain webhooks (Meta only lets you use one)

Has anyone dealt with this before? How can I get that second user input in my n8n workflow?

Here’s a simplified version of the JSON I’m working with:

[
  {
    "messaging_product": "whatsapp",
    "contacts": [
      {
        "input": "",
        "wa_id": ""
      }
    ],
    "messages": [
      {
        "id": "wamid.ABC123XYZ"
      }
    ]
  }
]

Any tips would be super helpful! Thanks!

I’ve encountered similar challenges with WhatsApp API integration in n8n. One effective approach is to implement a queuing system using n8n’s Queue node which allows you to process multiple inputs sequentially. You can set up the Queue node after your initial webhook to store incoming messages and then employ a loop to process each message one after the other. This approach respects the single webhook limitation while enabling asynchronous handling of conversation stages. It is important to integrate robust error handling and timeout mechanisms to ensure a smooth workflow.

have u tried using a loop node? it might help capture multiple inputs. also, check if there’s a way to keep the webhook connection open longer. maybe look into websockets if that’s an option with whatsapp api. good luck with ur project!

I’ve actually tackled a similar challenge with the WhatsApp API in n8n. One approach that worked for me was implementing a stateful workflow using n8n’s ‘Set’ and ‘Get’ nodes. Here’s the gist:

After the initial user input, use a ‘Set’ node to store the conversation state and user ID. Then, configure your webhook to handle all incoming messages. In the webhook, use a ‘Get’ node to retrieve the stored state.

This way, when the second message comes in, you can pick up where you left off. You’ll need to adjust your Switch node logic to account for different conversation stages.

It’s not the most elegant solution, but it gets the job done without violating WhatsApp’s webhook limitations. Just remember to clear the state once the conversation is complete to avoid confusion with future interactions.

Hope this helps point you in the right direction!