https://discord.gg/botpress logo
How to get the value of chat:profile in Botpress s...
# 🤝help
f
Hi guys, I'm currently working on the development of a chatbot to answer questions from a specific website. and this chatbot will be hosted by each specific website. Could you please help me to know how to get the value "NEO" stored in the profil tag in order to be able to use it in the workflowsof Botpress Studio. I'm using Python and chat API to communicate with Botpress and access the endpoint. I have used the endpoint "/users" in order to send the information on enterprise_name using the profile. In Botpress Studio, according to the value of enterprise_name, it will takes a different path (in order to provide a separate KB for each enterprise). I hope this will be clear enought. Please feel free to let me know if I should provide further infos. Big thanks to all for your help ! BR https://cdn.discordapp.com/attachments/1384512016848261194/1384512017376739468/30922171-3239-4A8A-AC24-A42ACCE11B76.png?ex=6852b2cb&is=6851614b&hm=b01b197a1c30c560cb7d93a44086faf77c86819ed2a4007a44c9ceb1f70c1e2e& https://cdn.discordapp.com/attachments/1384512016848261194/1384512017658024057/C78B023E-7050-4F17-A259-3F97ABF84B48.png?ex=6852b2cb&is=6851614b&hm=a130d9ff51302f35311da30c08de4ebe0f8a1f9741c643a8bf3d2a1b0d4af122&
p
Can you elaborate on what the tag is attache dto?
f
it is attached to the user
p
Right, you should try in an execute code card having the following code:
Copy code
js
const { user } = client.getUser({ id: event.userId })
user.tags['chat:profile']
It may only work once the bot is published and not in the emulator, though.
f
thanks for your help. unfortunately, it didn't work. i will continue to investigate from my side but if you have further idea, i would be glad to hear. Regards,
And if that doesn't work please provide the error you're getting.
f
hello again, thanks so much Leanne. Good news, this code works very well from my side (but only with the published bot, but not with the emulator) ! can you please explain why it's not working with the emulator please ? Also, how can I only catch the word NEOxxx rather than the whole JSON string {"chat:profile":"NEOxxx"} ? Tks so much again ! Regards, https://cdn.discordapp.com/attachments/1384512016848261194/1384630060958613654/image.png?ex=685320bb&is=6851cf3b&hm=68c21dd220b0de8078d3fbdf5ce5a8e8961338329e67763d9f3226887a57c602&
Also, please when I wrote the code you mentioned, it underlines in red the word "debug" like if it was not recognized. do you know why please ? https://cdn.discordapp.com/attachments/1384512016848261194/1384630858526494852/image.png?ex=68532179&is=6851cff9&hm=376ae4542763306430b283f0daec3e87fdb3c8bb661e8a6456f2aa988973724e&
p
Yes you would have to make the variable in the studio variable editor on the bottom left.
Regarding the format of the output you can sanitize the string within your execute code card. I would recommend asking chat GPt to give you the exact code.
f
Yep sure, I have updated the piece of code a litle 👍 Regarding your first sentence "*to make the variable in the studio variable editor*", did you mean that I should create the variable as shown in the attached screenshot ? unfortunately, it still produces an error in the emulator. I guess this is probably because it is empty from Botpress studio. 🤔 Thanks again. Regards, https://cdn.discordapp.com/attachments/1384512016848261194/1384635847097192610/image.png?ex=6853261f&is=6851d49f&hm=d23876058bebb88391415cd8caab56f4bfde977bf1629d2ff7f93881398eee8b& https://cdn.discordapp.com/attachments/1384512016848261194/1384635847466549248/image.png?ex=6853261f&is=6851d49f&hm=e86d5f699d2787a123121e44225783bc3d7297119ac62eeddd6f9f440fccdd63&
p
Yeah the fact it doesn't work in the emulator is expected as previously mentioned, you can use the preview to test your bot instead.
f
Ok Leanne, thanks so much for your support ! 🙏
p
No worries, happy to help!