Get user data when triggering a webhook
# 🤝help
m
Hi! Im trying to access to the "user" variables when using a webhook, but for some reason they seem to not exist. Im aware that I have to put manually the conversationId in the "event" object when the webhook is triggered, maybe I have to set another variable manually to get access to a specific "user" object?? Thanks!
s
Hi! It seems like you're trying to access the "user" variables using a webhook and facing some issues. You don't have to set another variable manually to access a specific "user" object. If the "user" variables seem to not exist even though you manually put the conversationId in the "event" object when the webhook is triggered, you can access the ID of the conversation created in Botpress Cloud by storing the output value of the webhook action in a variable. The output value will be an object with the conversationId. You can then use
{{ workflow.bpWhatsappAction.conversationId }}
in input fields of the Studio or use
workflow.bpWhatsappAction.conversationId
to access it in code. If you need further assistance, feel free to ask!
m
I would like human assistance in this, I don't think the bot is understanding what I mean
I can't access the user variables even though im manually inserting the conversationId in the event object. Please help in here!
Hello? why is nobody answering me :/
s
Hey @hola, could provide more details around how you manually set the
conversationId
in the event object?
r
@microscopic-butcher-43176 Are you setting the
conversationId
from inside a hook (if so, which one?), or from inside the workflow, or directly from the webhook payload?
m
Im getting the conversation Id from inside the workflow. It works like this: conversationId gets saved in a variable > conversationId gets sent in a POST request to the API that processes the call > API makes a POST request to the webhook and sends the conversationId in the payload's body > conversationId gets manually setted
Hey! I really need a response for this, as Im under great pressure because of my boss hehe
@fresh-fireman-491 this is the error, sorry i didn't @ u earlier
f
Hey there, and no worries
Will look into this
I take it that you are using the Webhook integration right? https://app.botpress.cloud/hub/integrations/6d68151a-186e-49c6-a128-940f9a60e673
General question. Where are you setting the conversationid?
m
yup, im using the Webhook integration
look the message earlier, I specify how im setting the conversationId
and, if you are asking for the variable where I store the conversationId when the webhook is triggered, Im storing it in event.conversationId, as the documentation states
the conversation flows perfectly after I set the conversationId. The thing is that I need to set some fields in the "user" object after the webhook is triggered, but I can't because the object appears to be empty even after I set the conversationId
f
Sorry my bad, missed the last part.
Where did you read that it should be in the payload body?
m
Idrk if it is in the documentation or in one of the webhook issues on github, but it is the only way it works lol
f
Based on what I read in the docs, I thought that it would always start a new conversation, as I couldn't really find something about the conversation id. Maybe @rich-battery-69172 or @famous-jewelry-85388 could enlighten us here?
m
I hope I can get help with this, Im in great pressure right now hahaha
Hi?
@famous-jewelry-85388 Sorry if im being annoying, I know that we are all busy... but I really need an answer 😣
f
hey @microscopic-butcher-43176 can you give me a report ID?
@square-energy-41150 how to generate a report ID
s
# Sending a Problem Report Here's how to send the Botpress Team a problem report: 1. In the Botpress Cloud Studio, locate the "Help" icon in the bottom left corner of the screen. 2. Click "Report a problem" and follow the steps on the screen. 3. Copy the Report ID to your clipboard and provide it to a member of the Botpress Team on Discord.
message has been deleted
m
@famous-jewelry-85388 report_01HRTEGVNKYJ2FSADFYD8AN53F
f
hey @microscopic-butcher-43176, So first of all, you have 3 web hooks, can you only keep 1? and remove the other two?
m
well surely i could think how to do that, why though?
f
Because it is not clear for the webhooks on which one to be fired. So let's start first with one webhook handling everything with transition cards to minimize the things we are looking into. Makes the troubleshooting easier.
m
ah cool then
f
Second point, how are you passing the userdata to the bot? Is it through the configuration (embedding code) or through the the webhooks?
that part wasn't clear for me in the thread
m
check the configuration workflow, I get that data from an excel (ik is not the best way, im working on a database, but lets say my boss wants everything for yesterday :p)
f
sure, no judgment. Can you guide me to which nodes do you collect the info?
m
it gets parsed and assigned in an user variable
For Configuration is the workflow
Sorry, For Authentication*
there is only one node there with multiple code snippets
the first one
f
got it, and the data is retrieved and saved in the user variable
m
yup
f
now your issue is you can't find those values when a webhook is fired?
m
ye, the user object appears to be completely empty when the webhook is fired
im using the Whatsapp integration btw
f
yes, after the webhook, you only set the conversation id variable... that's doesn't load the state
and the values are saved in the user object in the state
how many users are you expecting?
to chat with the bot
m
i couldn't really tell, im only the dev haha
but not a big amount of users for now, though
f
what I am thinking about is saving the info in a table, then fetching it from there
wait
can you tell me about the business?
m
i mean, yes, but it would be actually easier to take the time to do the database and work w the database
the project we are doing or my business specifically?
f
sorry I wasn't clear, yea the project. From business prespective, why do we have a conversation and then webhooks
m
the project is an accounting assistent, it facilitates the creation of bills via whatsapp
we need webhooks and conversations because the whole creation flows like a conversation
and the webhooks connect the data to a make integration that saves those bills in different drive directories
im planning to use the make card btw, great integration
ik the bot is actually pretty messy, as it is my first bot. I have experience coding this type of things, but my boss wanted to use botpress sooo, orders are orders
actually, now that i mention it, is it possible to make a whatsapp bot using the botpress SDK? i was checking the documentation earlier but it wasn't very clear to me if it only works for WebChat or if i can make any bot with that. Also, i didn't find any project similar to mines in github so i didn't went further
if it is possible, i'd like to see a project with code that makes a ws bot to see the whole code structure and folder structure and do the best practices
f
I read your message, but for me it is not clear where does the webhooks come. Like what fires it? why it is not part of the current flow, etc.
m
a make scenario fires that webhook
f
got it
I think the easiest thing to do is saving the data in a table and fetch it from there. You want to do it in an external DB, no problem.
For the whatsApp part. Where the problem for using the SDK with WhatsApp? can you elaborate or give me examples?
m
nah i don't have any problem, i just wanted to know if it is possible to use the sdk to make a whatsapp bot, and if there is a project that could serve for me as an example
f
it is the same idea, create a bot and add a whatsapp integration.
No we don't have projects that we can share
but it should be pretty easy
I think 🙂
m
well that is a shame
i'll explore the possibilities and update you with the info i get then
thanks fam
f
you're welcome. One Team 💪
m
@rich-battery-69172 @fresh-fireman-491 @famous-jewelry-85388 I'm back here with great news! This error can be fixed if you use the "Make" integration instead of the Webhook trigger. The Make integration works inside the nodes so it mantains the states even after receiving the webhook's response. This is actually very useful because you can put any kind of webhook inside the Make integration, not only Make webhooks, so you can see it like this Webhooks: doesn't loads the states but are async of the process and can be done anytime Make integration: keeps the states but are synchronous and only can work inside a workflow Again, thanks to @fresh-fireman-491 for this integration, I think this is bigger than he could even think!
f
Perfect! Decay is the best 🔥
@crooked-van-25152 will be happy with this feedback too!
@microscopic-butcher-43176 thanks for sharing the feedback 🙂
m
no problemo my hermano
f
That is amazing to hear. Glad that you found it useful!
c
Amazing!!!! Thanks for letting us know @microscopic-butcher-43176! And @fresh-fireman-491, thanks again for building this powerful integration! ❤️ You rock 🙂
f
Didn't realize it would work with all webhooks, but of course it does.
23 Views