https://discord.gg/botpress logo
Reading payload from a json webhook.
# 🤝help
b
Hey there. Im trying to load the payload for a webhook in the workflow veraibls but Its not working. Can someone pls help me with that?
a
Hey! I’ve worked with Botpress webhooks and workflow variables quite a bit — I can help you get the payload to load correctly. Could you share how you’re currently passing the payload into the workflow? For example, are you using event.payload or assigning it through a variable node? @brief-grass-59667
b
this is how the json looks like. I tried to store it in difrent way but no succssess. I think the core of the problen is that after running the test i look for event.payload.body but its not there. I can find only event.payload https://cdn.discordapp.com/attachments/1432685141255262278/1432692568709140581/image.png?ex=6901fa6e&is=6900a8ee&hm=73919613454b01fc21c19b28207fea713380d498d9b89156b2eb44189b66b2ef&
a
Hey! I see exactly what’s happening with your webhook payload — the body is nested inside event.payload, which can sometimes cause issues when accessing it directly in workflow variables. I’ve dealt with this before and can help you properly map it so you can use accountname, telephone1, and accountid without errors. @brief-grass-59667 If you want, we can hop into a quick private chat to go through your setup and get this working smoothly.
b
lets do it
a
Awesome 😎
w
@brief-grass-59667 Are you sure? put a text card with this:
{{ event.payload.body.accountname }}
and try in emulator. If you see it in red instead of green, it's an IntelliSense error because IntelliSense doesn't know your payload structure.
@brief-grass-59667 @astonishing-dream-61762 , it's better to post here and not in private; that should help other users.
l
Thank you for your help @User @User As Zannax said its better to help users here to that others can learn! If anyone has a similar issue in the feature this help thread can help educate them 🙂
b
the problem is when i type {{event.payload.}} I dont see the body option with the veribles
w
It'd be intellisense problem only, try to output {{ event.payload.body.accountname }} in a text card connected to webhook trigger event
b
ill try. whats intellisense? for now i was trying to use it in a whatsapp start conversation card
w
IntelliSense is a coding feature that provides real-time suggestions and auto-completions for code, making it easier for developers to write and understand code efficiently. It includes features like code completion, parameter info, and quick info about functions and variables.
b
thats actually workd. such a wierd system. it doeesnt show me a veriable is there but in the emulater it spits the right json in the emulator. there is a way to fix it? showing that the veriabke is there? store it as a veriable i guess
w
The
event.payload
is an object that can vary; it changes for different events, so it's not easy to define the rules for showing the right suggestions.
b
I see. I am srying to store the payload in a veraible but it doesnt work. maybe you know why? thats the code im using. const accountName = event.payload.body.accountname // Get the account name from the event payload workflow.accountName = accountName // Store the account name in the workflow variable
w
The code seems to be ok; Sorry for foolish question, but have already create
workflow.accountName
? You cay write only
workflow.accountName = event.payload.body.accountname
In the node with the execute card put a text card with
{{ workflow.accounName }}
b
haha yes I create it. and the mark that shows is not used had disapperd but the value is not there
w
Please send image of workflow and emulator with the empty value