Pass user data to webchat and use it in the workfl...
# 🤝help
b
Hello I am trying to pass user data to the webchat like for example, user id, user name, etc. And then be able to use that data in the workflow to do different things for example calling a REST Api to show the user specific information in an external system. Please see attached the pic with the parameters I am using to initialize webchat. Now in the workflow side I am trying to use the Get User Data card to get the user data. But is not working for me, if someone could point to the right direction here, Thank you!

https://cdn.discordapp.com/attachments/1142100513807155250/1142100513983307826/Screenshot_2023-08-18_at_10.14.50_AM.png

m
Hi, @brash-fireman-56077. Theoretically you just need to add the card "Get User Data" in that card you must define the userID with {{event.userId}} and choose a variable (object) that will contain the data placed in the UserData. After that, it is necessary to create a Code card to pass the data of this object to variables, in your case it would be: Workflow.name = workflow.ObjectName.userData.name In this line above I'm accessing the name inside the object, remember to replace this objectName with the name of the variable you put in the "Get User Data" card. Sorry my english is very bad ;-;

https://cdn.discordapp.com/attachments/1142100513807155250/1142109362559664158/image.png

https://cdn.discordapp.com/attachments/1142100513807155250/1142109362849063092/image.png

https://cdn.discordapp.com/attachments/1142100513807155250/1142109363209781288/image.png

🤔 But I'm having a problem with this and I would like to take the opportunity to clarify this doubt as well. In my case I'm trying to pass the URL of the page in this parameter because each user will enter a page with a different token. I'm trying to use it this way: userData:{url: window.location.href} It works! but only with a user, if I open it in an incognito tab it leaves the object as "{}" in this example I am returning the {{event.userId}} and the @workflow.ObjectUser:

https://cdn.discordapp.com/attachments/1142100513807155250/1142111047285739631/image.png

https://cdn.discordapp.com/attachments/1142100513807155250/1142111047705182389/image.png

b
Thanks @microscopic-lizard-92513 I will try the way you did it and let you know the results.
Ok I tried that, this are the results

https://cdn.discordapp.com/attachments/1142100513807155250/1142125379847467008/Screenshot_2023-08-18_at_11.58.01_AM.png

https://cdn.discordapp.com/attachments/1142100513807155250/1142125380141076691/Screenshot_2023-08-18_at_11.57.52_AM.png

https://cdn.discordapp.com/attachments/1142100513807155250/1142125380396924928/Screenshot_2023-08-18_at_11.57.44_AM.png

https://cdn.discordapp.com/attachments/1142100513807155250/1142125380698910872/Screenshot_2023-08-18_at_11.57.25_AM.png

I am getting empty every time.
I just logged what is in the workflow after Get User Card is executed.
m
It didn't work then ;-; sorry. I think we are really going to need some help from someone at botpress team.
b
Thanks anyway.
513 Views