https://discord.gg/botpress logo
#🤝help
Zapier ---> Sheets Best Practices
# 🤝help
f

fresh-jelly-85561

07/06/2023, 7:52 PM
So, I've built a drink ordering bot. Basically it asks you to make an order from one of the menus favorites, kids etc. and then you choose which flavor from there, then it asks you which size, and finally asks if you'd like to order another drink. I'm having a hard time finding the right place to capture the variables name, flavor, size to send to zapier and then sheets. The name one is working but it's only needed once, the others need to be captured each time a drink is ordered before a user says they want to order another drink which then overwrites the stored variable. Any thoughts from anyone? I can show the diagram if helpful. Thanks!
c

careful-keyboard-68830

07/06/2023, 8:48 PM
You can perform a question loop which bypasses the first node. Where the first node is the one that asks the user's name. The last node ends with ordering more drinks? With a yes no option. If no then the bot ends. If yes, the bot loops back to the drinks questions, bypassing the name.
f

fresh-jelly-85561

07/06/2023, 8:50 PM
Yeah, I've got the name bypassed so it only collects that variable once, but the bot will ask "Do you want another drink" and go back through the order process at which point the variables get overwritten from the first drink order. So I need to have an intermediate code block that shoots off either each variable individually as entered or at the point right before would you like another drink.
And if I try to do something like this, then it ignores the code and just goes to the next stage.
c

careful-keyboard-68830

07/07/2023, 5:08 AM
Yeah this won't work because the code card is below the input card.
Could you maybe have the bot send to Zapier after the person clicks yes to "another drink?" Like link a new node that has the code card that sends the variables to Zapier. Then do an Flow Logic card to get it loop back to the beginning?
that way your variables get sent first before it gets overwritten
apologies if I do not get the full picture
f

fresh-jelly-85561

07/07/2023, 5:11 AM
Like this?
Was thinking instead of variable to change to arrays, so more than one value could be stored. I'm a pretty rookie code person though so not having great success.
That's my code
// Assuming these variables exist in your context let SodaType = 'SodaType'; let size = 'size'; let name = 'name'; let flavor = 'flavor'; // URL of your Zapier webhook let zapierWebhookUrl = 'https://hooks.zapier.com/hooks/ // Prepare your data let data = { 'SodaType': SodaType, 'Size': size, 'Name': name, 'Flavor': flavor }; // Send a POST request to the Zapier webhook fetch(zapierWebhookUrl, { method: 'POST', body: JSON.stringify(data), headers: { 'Content-Type': 'application/json' } }).then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }).then(data => { console.log('Success:', data); }).catch(error => { console.error('Error:', error); });
And it does all this, says variable captured etc. Just can't get the output to send to zap
Disregard all - Got it working. Here's the final flow
So if you say no more order, it sends variables, if you say yes another order it then sends variables and goes back through loop
c

careful-keyboard-68830

07/07/2023, 10:28 AM
Solid flow you've got there!