https://discord.gg/botpress logo
When a workflow is triggered, the user and convers...
# šŸ¤help
w
I have a bot with a webhook. Inside the webhook there’s an Execute card where I need to read user and conversation scoped variables. I’m passing
conversationId
and
userId
to the webhook, but the variables come back empty. This is the report ID of a test bot: **report_01K2319T24Y7431WZNCR2PGFQE**: - When the conversation starts, I set a numeric and a string variable. - I display the variable values in the chat. - Via Postman I call the bot’s webhook with two query parameters: conversationId and userId. - When the workflow is triggered, it reads and then it writes the variables in the chat; but the values are empty string and 0 @loud-crowd-60573 @loud-crowd-60573 https://cdn.discordapp.com/attachments/1426224405343768696/1426224406048276522/image.png?ex=68ea727c&is=68e920fc&hm=1ec93a1381f500240f2b5b8a9388cca71feb3d64132b88ff16d65161e45d6a9a&
w
yeah that's been happening for a while
but getting the variables from the webhook's call still works for me. are you accessing them correctly?
maybe passing them on the body instead of the params will resolve it
w
I call the webhook, passing conversationId and userId, and they are correct. The webhook goes to the node that prints the second message, but when I try to read the user.myString variable it’s empty instead of containing ā€œHello User!ā€
w
shouldn't it be event.user.myString then, if you're extracting it from the webhook?
can you please send a screenshot of your request body in postman?
w
i need to read the scoped user and conversation variables that the chatbot set during the conversation
w
shouldn't it be a post?
does your execute card read the variables FROM THE WEBHOOK?
w
no, the problem is not the webhook, the call is working, trigger goes to the right node, but the variables have default values. - the first message in the picture is a text card with the value of variable setted by an execute card - the second message is a text card that print the variables. **EC to set values**:
Copy code
ts
user.myString = 'Hello User!'
user.myNumber = 10
conversation.myString = 'Hello World!'
conversation.myNumber = 20
Text Card:
Copy code
## User
{{ user.myString }} = {{ user.myNumber }}
## Conversation
{{ conversation.myString }} = {{ conversation.myNumber }}
w
yes but the webhook leads only to the text card, right?
the problem is your variables are wiped when triggering the webhook
one solution is to make the webhook a POST and then pull those variables from it
so the webhook body would be
Copy code
json
{
  "user": {
    "myString": "Hello User!",
    "myNumber": 10
  },
  "conversation": {
    "myString": "Hello World!",
    "myNumber": 20
  }
}
for example
and then after triggering the webhook, you have ANOTHER execute card node that does
Copy code
javascript
user.myString = event.payload.body.user.myString
user.myNumber = event.payload.body.user.myNumber
conversation.myString = event.payload.body.conversation.myString
conversation.myNumber = event.payload.body.conversation.myNumber
w
It's a good solution if i need to set the variables; but i need the webhook to trigger some actions, in chatbot, reading variables already setted during the conversation
w
tiny correction - they aren't "wiped" so much as they never actually existed
testing these types of integrations on the emulator is painful because none of your conversations or users actually exist
then maybe you could try it on a real conversation with a real user
like one on webchat, whatsapp or created using the messaging apui
emulator runs aren't saved and they're actually on a completely different format from the real variables
also you'd need to fill these out probably, so the webhook knows WHAT conversation and WHAT user
w
Here https://discord.com/channels/1108396290624213082/1426224405343768696/1426225018282704999 the export of my test bot, i set those field reading them from webhook, and publishing the bot on webchat
w
i'll take a look hang on
w
Don't worry i think this is a bug or a limit of webhook integration
w
eh. could be.. i personally don't use webhooks for this reason
i'm gonna test it out anyways
@white-nest-40686 can confirm you're doing everything perfectly. really is an error on botpress's end
the only solution for now would be to create a hook to save the variables you need, then when posting to the webhook, use the body to pull the same things you saved
with something like n8n
i can help you set that up
w
Thanks
Don't worry, it's not a problem. I hope @loud-crowd-60573 checks it
w
okay!! sorry for not finding a better solution, i hope it gets fixed
w
Your suggestion is good, but I already have my APIs to store some basic info like conversation ID and user ID to trigger actions in the chatbot, and I don't want to save all variables on my side. šŸ˜‰
If Botpress Runtime API had an endpoint to retrieve user and conversation variables, it would be very useful.
l
Taking a look @white-nest-40686
s
Hello, having the same issue here !