https://discord.gg/botpress logo
Generating unique IDs + User variables
# 🤝help
c
Hi all! We've developed a survey in Botpress, with questions spread across several cards. Our primary goal is to accurately correlate responses (from each respondent) across all five tables to ensure the integrity of data analysis. We aim to export all these tables for further evaluation, so it's crucial that each respondent's answers are reliably linked from tables 1 through 5. This will help in eliminating any biases and ensuring precise data interpretation on an individual basis. From what I understand, this can be achieved using User variables, allowing the bot to assign a unique user ID at the start of the conversation. This ID can then be included in the tables to consistently associate the responses with the correct person. Could anyone guide me on how to implement this? I have watched some YouTube videos, however the interface has changed a bit. Thanks in advance!
l
event.userid and event.conversationId will give you user and conversation details, grab them into user variables and add them to tables
c
Hi Lijo, Thank you for your message. Currently, our bot is not implemented anywhere. I am testing the bot in the testing environment/preview Botpress Webchat. So, can I still use events if I only share the link with people, without actually integrating it anywhere? I am asking since I have seen events are linked with JavaScript/iFrame.
l
You should still be able to use it, as events is internal to Botpress
c
Thanks! Is there any link/thread where I can find more information about how to implement it?
o
You can set it via execute code card just using example:
Copy code
js
user.ID = event.userId
user.conversationId = event.conversationId
where I'm assuming the user variables were already created. You can then upload them to a table as you'd like. Please note that if you test this out in the emulator, it will work but you'll have fake values. (ex: your conversation id might be "convo-1" or "convo-2" but that isn't really what a REAL botpress conversation id looks like. it is placeholder values for the emulator)
c
Thanks, Matthew. I will try this!