Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get User Data not working #12998

Open
H-JonathanLoise opened this issue Feb 18, 2024 · 27 comments
Open

Get User Data not working #12998

H-JonathanLoise opened this issue Feb 18, 2024 · 27 comments
Assignees

Comments

@H-JonathanLoise
Copy link

H-JonathanLoise commented Feb 18, 2024

Hi,
I'm using reactjs with botpress and I'm trying to send userData to the bot.

As you can see in this image my user variable is not found and also if I create a new one it creates a workflow variable, but also using the workflow variable it is not able to retrieve the frontend user data sent:
image

In this second image you can see that I initialized the data variable but the studio as still the label "not set":
image

This is my reactjs code and you can see I added the userData:
image

Testing the bot from my react application I always get undefined, so this means that is unable to read the react userData values.

Am I doing something wrong or there're issues by your side?

Regards,
Jonathan

@H-JonathanLoise
Copy link
Author

Hi, any news?
I saw that during debug I can see the data filled with the default value instead of "not set" but I still don't see the userData I pass from my client application.

J.

@H-JonathanLoise
Copy link
Author

Just tried to execute code that move datas from the workflow variable that contains the user data to a user variable, still not working

@H-JonathanLoise
Copy link
Author

Hi,
still waiting.

Regards,
J.

@jgaltio
Copy link

jgaltio commented Feb 28, 2024

@H-JonathanLoise I'm just another user struggling with a related, but different, issue however if I understand correctly, perhaps I can help.

You're showing a custom config for the webchat then showing screenshots of the cloud editor variables. The view of those variables and their values are populated by using the emulator, not the deployed webchat. You can add console.log() statements in the studio then go to the dashboard's Logs (the ones outside of the studio blueprint editor, not the emulator logs inside it). Then you can see the variables' values for your deployment.

Also, regarding the first screenshot, you didn't type user. before the variable name.

@H-JonathanLoise
Copy link
Author

Hi @jgaltio,
during my test I saw that variables was populated using the emulator, however thank you.

About the first screenshot, If i type user.{variable} the dot is removed automatically, I can only fill or create a workflow variable. Currently I set a custom code to mode the workflow variable content into the user variable but the user data from my reactjs application are not captured.

Thank you for your support, really appreciated.

@franklevasseur
Copy link
Member

Hi, @H-JonathanLoise

Sorry for the late reply. To tell the truth, I don't know the answer to your question. I'm not sure if the bug is studio-related or webchat-related by simply looking at the information you provided. We are currently working on releasing a new version of the webchat with better documented API.

In the meantime, I'll leave the issue open and poke around the rest of the dev team.

You can also try posting your issue on our discord server, you might find an answer over there.

Frank

@franklevasseur franklevasseur removed their assignment Feb 29, 2024
@H-JonathanLoise
Copy link
Author

Hi @franklevasseur,
thank you, will try asking on discord and will look the next days if it automatically fixes maybe with some your releases.

Regards,
Jonathan

@fosteman
Copy link

fosteman commented Mar 1, 2024

@H-JonathanLoise , hang in there, i'm building a fiddle to replicate this.

@fosteman
Copy link

fosteman commented Mar 1, 2024

Here's my fiddle

And bot configuration:
Screenshot 2024-03-01 at 09 29 20

@fosteman
Copy link

fosteman commented Mar 1, 2024

considering this is in the docs:

it should work. but i can't get it to respond right now either.

@fosteman
Copy link

fosteman commented Mar 1, 2024

thoughts ?

@fosteman
Copy link

fosteman commented Mar 1, 2024

issue.replication.mp4

@H-JonathanLoise
Copy link
Author

Hi @fosteman thank you for your support.
The doc at this link https://botpress.com/docs/developers/webchat/controlling-webchat-using-js/#send-user-data-from-your-website-to-botpress says
image

So you have to retrieve the user data using the specific card and that is what I did:
image

Then I moved that data inside the user variable:
image

And in the last I used the text card to say Hi to the end user:
image

But this is the result:
image

Regards,
Jonathan

@Topiksit0
Copy link

Hi, any news on this? Same problem here.

@H-JonathanLoise
Copy link
Author

News?

@EFF
Copy link
Member

EFF commented Mar 21, 2024

Hi guys this is fixed and pushed in production :) feel free to re-open if needed

@EFF EFF closed this as completed Mar 21, 2024
@Topiksit0
Copy link

Topiksit0 commented Mar 22, 2024

Hi guys this is fixed and pushed in production :) feel free to re-open if needed

Still not working for me, @H-JonathanLoise did you fix your problem?

@franklevasseur franklevasseur self-assigned this Mar 22, 2024
@Topiksit0
Copy link

Let me add some more info about my problem here:
https://discord.com/channels/1108396290624213082/1220059353730650132

@franklevasseur
Copy link
Member

It works perfectly on my side since eff made the fix. @H-JonathanLoise, can you confirm ?

@H-JonathanLoise
Copy link
Author

Hi @franklevasseur is not working.

image

image

Could you share the screens of your test?

Regards,
Jonathan

@H-JonathanLoise
Copy link
Author

Hi, any news?

J.

1 similar comment
@H-JonathanLoise
Copy link
Author

Hi, any news?

J.

@franklevasseur
Copy link
Member

@H-JonathanLoise

Still can't reproduce on my end, setting user data and getting it works for me... I tried on webchat v0, v1 and on the new frontend v2...

@Topiksit0
Copy link

Hi @H-JonathanLoise , I just found what was my problem, the attributes that I passed to userData needed to be strings, I was sending integers and because of that it wasn't working, hope this can help you.

The solution was just parsing the integer into a string:
image

@H-JonathanLoise
Copy link
Author

Hi @franklevasseur @Topiksit0,
I see in your examples you just pass a string, but in my example I pass a complex object, does it work on your side with complex objects?

Or if I pass a json string, can I transform that string in an object in the botpress WF?

J.

@Topiksit0
Copy link

Hi @franklevasseur @Topiksit0, I see in your examples you just pass a string, but in my example I pass a complex object, does it work on your side with complex objects?

Or if I pass a json string, can I transform that string in an object in the botpress WF?

J.

Hi @H-JonathanLoise , it won't work with a complex object, I recommend you to just stringify the object

@H-JonathanLoise
Copy link
Author

@Topiksit0 ok thank you, but I think it's possible in the botrpress WF to convert back that json string in a javascript object and save it in a separated variable, right?

J.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants