https://discord.gg/botpress logo
Managing data from api response.
# 🤝help
p
-I am currently making a get request to get upcoming booked appointments for a specific user. -After getting the response i am assigning the data to a variable in a execute code card like so. workflow.fetchedDates = workflow.apiCardName.response.data.data. -The data held inside of the variable fetchedDates would look something like this if the user had more than 1 appointment: [ { "id": 123456, "uid": "9891726", "title": "Discovery meeting between host and user", "start": "2025-07-29T11:00:00.000Z", }, { "id": 123457, "uid": "2611091", "title": "Discovery meeting between host and user", "start": "2025-07-29T14:00:00.000Z", }, ] -How can i allow the user to specify which of the appointments they would like to take action on? As i am going to be adding the workflows for cancelling and rescheduling getting the uid of a specified appointment is required to move onto those api calls. I can give more context if my issue is unclear. Thank you in advance to anyone who is able to help!!!
p
You could pass that variable to a single choice card, it will create as many buttons as there are events. Hope this helps!
p
Great idea! That is the only way I have gotten close. My issue is this is happening in a sub work flow. I am capturing the selected value from the single choice, storing it in a workflow variable that I add to the exit node of that workflow. Then when I get routed back to the main work flow, it says cool I’ve fetched these dates, even tho I had just specified in the other work flow which choice I had picked. Sorry wordy and might not make total sense, I really appreciate your help!!
I can provide screen shots
p
To call a sub-workflows variable you would do it as such: workflow."subWorkflowName"."variableName" If that does not answer your question please elaborate.
As you can see in the chat emulator we enter the 'existing appointment' workflow where we give the user a single choice of their upcoming appointment, the user then selects the appointment they are referring too and the 'uid' from that single choice card is saved to the variable 'theAppointment' which is then placed in the exit node of the 'existing appointments' workflow. the conversation then routes back to the main workflows autonomous node but does not realise the completion of the task and ask the user again which appointment they are referring to.
The only thought i had to break through this dead end, is have the user the user specify if they need to move onto the 'cancel' or 'reschedule' after the single choice, so that the 'theAppointment' variable can be passed onto the next workflow and used right away with the logic respective to the workflow.
p
What is the rest of the task? You could add it before the workflow returns or after the exit node (enabled) in the main flow.
p
My next task following the 'existing appointment' is 'cancel' or 'reschedule' based on the users intentions, both 'cancel' and 'reschedule' workflows require the uid extracted from the single choice in 'existing appointment'
similar to have i have set up 'CreateAppointment' workflow except this time the values are coming from a api not user inputs. https://cdn.discordapp.com/attachments/1399578476922540052/1399825269979877486/image.png?ex=688a685f&is=688916df&hm=0a42ee2b34d60f6c307a3133b60ef795397b72ef06495d571bbbd2b31e3fa8fb&
userInfo in that case is a schema variable that expects name, email, and start
p
As mentioned above one option is forcing the input value to workflow."subWorkflowName"."variableName". Alternatively you can call a sub-workflow from the existing appointment workflow by using its card.
p
Thank you so much! I know there are so many questions being asked and really appreciate your time and help @prehistoric-airplane-85682, I am just slightly confused how to do this -"As mentioned above one option is forcing the input value to workflow."subWorkflowName"."variableName"." Would it look something like this? Sorry for taking so much of your time https://cdn.discordapp.com/attachments/1399578476922540052/1399828693022539978/image.png?ex=688a6b8f&is=68891a0f&hm=5524830bc40e334fff4f072ca59d6d6e1973b9690afeb5028f8834000d9c151f& https://cdn.discordapp.com/attachments/1399578476922540052/1399828693387579412/image.png?ex=688a6b90&is=68891a10&hm=3358e313d7231391244f2103bb6cd9bb9138b3965a2be8019257b16f11336a70&
p
No worries! If theAppointment variable contains the uid then yes this should work.
s
I'm having a similar issue, pasted from the help section: Copied from the Discord 'Help' channel: I've attached a video for extra context. So I have a workflow that is initiated with a custom trigger, triggered by my website sending an event to webchat. When the workflow is triggered, it continues through the flow without any issue, up until the point where it get's to the single choice block. I've never had this much of an issue, but Botpress refuses to move on to the allocated node after the user selects a choice. Sometimes, when a user selects a choice, the conversation just ends and nothing happens. Other times, when users select a choice, the conversation goes to the Autonomous node which is in a completely separate workflow. No matter what I do, selecting a choice never transitions onto the next node in the workflow like it should. I've tried saving the selection of the single choice block to a variable to use an AI Transition to move on to the next node. I've tried a Execute Code block. I've tried using the deprecated Intent block. I've tried using the standard Single Choice transitions. I've added On Fail options to the Single Choice, and adding a Wait For User Input after the Single Choice. It makes absolutely no sense to me, looking at logs give me no indication of why this happens. Has anyone run into this issue before? From the video, does anyone have any potential fixes I haven't thought about? I've never run into this issue before, been building bots with Botpress for the last two years. I've built this exact workflow for a different bot on another website which works without any issue. Any and all help greatly appreciated!
P.S. sorry for hijacking the conversation lol
p
Then I would recommend calling the cancel or reschedule workflows from the Existing appointment workflow aftre your capture information card.
p
Sounds good, thank you
p
Happy to help!
p
Hope to show you the fully functional booking agent soon!
Working like magic now! I added an autonomous node to the exit node of the 'existing appointments' workflow. The new autonomous node will handle if the user then wants to cancel or reschedule and move onto the relevant workflow. Just did two test ruins of booking an appointment and cancelling. Working so good, and speedy fast. You are the GOAT @prehistoric-airplane-85682 https://cdn.discordapp.com/attachments/1399578476922540052/1399853974810525726/image.png?ex=688a831b&is=6889319b&hm=580532c1a06d7244bd8dfc936fb321cc21fc6aee481778f3d7af1e41b863a810&
Through trial and error, it seems that the life cycle of a variable which: subworkflow -> parent workflow must be re written into a new variable of the parent workflow if you would like to access its values outside of the subworkflows card.
Seems even more successful if those values get written into a schema variable in the parent workflow
3 Views