Reply To User via Webhook
# 🤝help
w
Hi everyone I'm trying to reply to a user chat via a webhook - currently doing this as proof of concept with postman but will do via my server in production. Currently I'm logging user, conversation id and message id as per below. userId user_01HY5MHP0VSPRF423MZ8J2CWT2 conversationId conv_01HY5MHNWRZ8FB57JNJNCHTVM5 messageId 2c1f94ef-e750-40c9-a6fd-2e2a5a117db9 Does anyone know what the payload should look like to message the user back via webhook? I've also recorded a loom to outline the issue: https://www.loom.com/share/c680b5e4f5a74e3585394b6f6b0dd212 The payload I'm responding with at the moment looks like { "userId": {{userId}}, "conversationId": {{conversationdId}}, "messageId":{{mesageId}}, "type": "text", "text": "text", "payload": { "foo": "bar" } }
w
hi @white-butcher-63858 , in the video you shared, you try to catch the webhook with the "conversation started" trigger
but did you enable the webhook integration ?
w
I had thoughtp, is that a separate integration available in the hub? I'm using the messaging endpoint integration from the hub I think
yes you have to install it on your chatbot
and then you can send webhooks and retrieve data
w
This all looks like my set up
w
{{event.payload.body.conversationId}} in your case
w
But thanks
w
not the one in your video
you have a conversationStarted trigger in your webhook workflow
that should be a webhook trigger
w
thanks @wooden-beard-40210 I've now updated this
the webhook is receiving the event from postman
and, on receipt should send a text card "i got a webhook event" but doesn't seem to progress - any advice on how to debug from there?
w
glad it works !
did you specify the conversation id ?
the problem with webhooks is that you have to specify the id of the conversation in which you want to display a message following a webhook trigger.
we can do it dynamically
{{event.payload.body.conversationId}}
it retrieves the conversationId you sent via the webhook
but you have to be on this specific conversation to see the message
thanks @wooden-beard-40210 i'm dangerously close but not quite
something in my syntax on conversation id I think
{{event.payload.body.conversationId}} doesn't seem to work so trying {{event.conversationId}} perhaps?
w
{{event.conversationId}} gives the current conversationId but doesn't work to assign the conversationId after a webhook
i suggested {{event.payload.body.conversationId}} because of the structure of your webhook
it's something like this : { "conversationId": {{conversationdId}} "text": "text" }
w
{ "userId": " ", "conversationId": " ", "messageId":"", "type": "text", "text": "text", "payload": { "foo": "bar" } } that's the payload i'm sending in response
w
so to acces the convid, you have to use {{event.payload.body.conversationId}} (check carefully the writting) and to get the text you have to use {{event.payload.body.text}} for exemple
hum okay
but do you send the convId when you send data from botpress (maybe you explained it inn your first video in don't remember) ?
note that you can't make it work in the studio
w
I do - and in fact i'm printing the conversation id to the console and the chat as well just to avoid doubt
then using those values in my POST request back to my webhook
i'm sorry there is no sound in the video i can't talk at the moment but you have an overview of what you have to do
i use make to retrieve data and resend them
the first time it doesn't work because i didn't run the make scenario
hope this will help 🙂
w
no problems - you are super helpful
just testing now
works!
w
Great !!
a
Hi there, thank you for all your help and i am sorry to go back to this but for some reason my bot still wont work and it seems its the same issue. The bot does receives the webhook back from make, but with no data on it. Or at least it wont show it. https://www.loom.com/share/871d86099193458db93fdc8ce11e3171?sid=22470167-7e43-47f7-86ab-a98f47316946 Can anyone help me with this? Truly appreciate ... i am running out of options here 😆
w
I’m on my phone right now , so I will try to help you more tomorrow
But from what I saw in your video, all looks good..
a
Thank you!! Whenever you can, sure will be really appreciated.
I dont know if that good news or bad news lol But yes... tks again, mate.
w
More a bad one I would say 😅
But I come back to you tomorrow
French hours 😂
a
Lovely, tks a lot.
w
I thought i found something wrong in your configuration, but again all is good ...
the last thing you could try, is to add a secret key in the botpress configuration for the webhook
in theory that changes nothing, but....
in your http module in make you just have to add a header : x-bp-secret : your-secret-key
One time something like this happened to me, and I tried to shorten the json in the http module (like
{"convId":"___","text":"____"}
instead of
Copy code
{
"convId":"___",
"text":"____"
}  
`
and it worked, but i don't thing this have a real impact
keep me updated..
Also verify that the text you are sending (data gathered from google sheet) is not that much big (you can test just with an http module and test data)
a
Amazing, thank you. I will test it today and share the results asap. Ps: When i do perform the http request on make alone as a test, I can see it being received by the botpress webhook in "discovery events"
improvemetns were made !!! Tks Now, the bot will eventually return the body text and body convid but only after it fails few seconds earlier. I show it here: https://www.loom.com/share/bb07c2d0e198484d821b2d475d718b84?sid=e0964a8c-6298-4030-9243-79e5ae2b63b7
w
That’s a first improvement !
Will have a look
a
Ideed Tks again.
w
Wow that’s weird
Looks like the bot needs a bit of time to process the information, so just try to add an “execute code” card and ask AI to wait for 1 or 2 seconds for exemple
a
WE DID IT
thank you
crazy solution but one that can help ppl in the future Creating the trigger node "from nothing" instead of creating it from a previou node - even if there is no connecting line between those nodes.
can't thank you enough for you patient and good will 🙏 @wooden-beard-40210
w
oh wow
unfortunately I couldn't see it 😂
glad it worked !!
a
yes, impossible to see it since there is never the connecting line
136 Views