Help with Webhooks
# 🤝help
Hello everyone, I am attempting to use webhooks to send a payload to my bot so that I can send data from N8N (Zapier/Make Alternative) to Botpress and use it in conversation. To do this, I am using an HTTP Request node and sending a "Post" request (see picture 1, 2 and 3). The Bot receives the request just fine, and I am able to see the payload in the Botpress emulator. However, when I try to use the data in an active conversation after publishing the bot, I keep getting this error: error: Bt [Error]: request/body must have required property 'userId'. I have the user Id correct, as I get it from botpress, send it to N8N, attach it to the payload, and then send the N8N data (along with the conversation and user ID) back to Botpress. I was getting this error with "conversationId" as well, but that has since stopped, so it appears to be receiving the conversationId correctly, but not the user ID for some reason. Anybody know why this is happening and what I might be able to do to fix it? Any help is greatly appreciated! Thank you.
Can you send a screenshot of your workflow in Botpress
Here is the workflow and here is a screenshot of the other execute codeblock which is attatched to the "Start" node of the conversation - if it helps. The way I have it setup is the conversation starts, then the code block captures the conversation Id and user Id and sends it to N8N via webhook. Then I have a "Wait for User" card that I wait to reply to until the Webhook trigger has captured the necessary data. I've tried also discarding the initial node and using the Webhook trigger to start the conversation, but I still run into the same problem. The webhook is capturing the data I'm sending (see above picture), but when I try to use it in conversation I keep getting that same error.
I'm getting this error in N8N (if it helps), which is weird because the data is being received within the Botpress emulator, I just can't use it in conversation.
What are you sending back to N8N?
You can't use the text card in the flow of a webhook.
You can use the Botpress client to send messages if you want
Hey @fresh-fireman-491, the issue I'm running into sending information from N8N to Botpress. When I send from Botpress to N8N, it works great! However, when I try to send a payload to Botpress from N8N, that is where I'm having difficulty. The payload sends, and it is received from N8N and appears in the Botpress emulator (see picture), however, when I try to assign it to a workflow variable and use it in conversation, that is where I'm getting the "userId" issue.
You cannot use a text card in the flow of a Webhook, as of my knowledge
Maybe a @User knows a way to do it? Otherwise you can use the API which I gave link to earlier
Hey @freezing-morning-36045! Did you test the bot in studio emulator, or in the sharable link?
Hey @bland-agent-12616 Both! Within the studio emulator, I am able to use the discover events within the "Webhook trigger" and use the data in conversation effectively! It's when I use it outside of the emulator (such as the shareable link) that I run into issues. I'm not not sure why it's happening, but I think it has something to do with the "userId" not being attached to the payload correctly. I found this thread which appears very similar to the issue I'm having, however mine is "userId" and not "conversationId":
I did something similar for a shopify bot
And this is the only code I had after the webhook trigger
Copy code
event.conversationId = event.payload.body.conversationId
So I'm guessing its a problem with your make setup
Can you show the make scenario modules?
@careful-kitchen-31087 Here is my setup and current code cards. I've kind of just been putting together what I've seen work for other people, but I'd be very interested to try your method!
Hey @bland-agent-12616, thanks! I tried attaching the conversation and userId to the payload after it had been received using a code card, but I kept running into the same issue. I think you're right and it something with my setup. I'm using N8N instead of Make, so probably some differences in the payload structure.