How to retrive and save row data into a variable u...
# 🤝help
g
I have a system set up where a user input for a product is captured and sent to Make using webhooks, which is connected to a G Sheet. Make is supposed to check whether there is a Product name match in the Sheet, and then send back the corresponding rows which contain details like price, availability, etc. I have a webhook going into a sheet and then into a response webhook outputting the relevant columns. My webhook connection is working fine. But how do I receive the data and use it later in the workflow?
async function saveDataToDataPack(workflow) { try { const response = await axios.post('https://hook.eu2.make.com/islujny85klphnug08u6jzhgggx84g', { finalItem: workflow.finalItem }); // Check for successful response if (response.status === 200) { // Extract data from response (assuming response.data has the structure) const product = response.data.message.data.Product; const priceKG = response.data.message.data.PriceKG; const availability = response.data.message.data.Availability; // Create the dataPack object const dataPack = { product: product, priceKG: priceKG, availability: availability, }; console.log("Data saved to dataPack:", dataPack); // You can now use the dataPack object further in your code } else { console.error("Error:", response.statusText); } } catch (error) { console.error("Error sending data:", error); } } // Assuming you have the workflow data saveDataToDataPack(workflow);
The codeblock is going haywire at this point and I have no idea what is going on. Too many reiterations using inbuilt AI + Gemini.
I probably need to send a simple webhook request, and then another code block to recieve the data and store it in an object or something. That seems logical to me but I'm not sure.
f
Hey there @gorgeous-zebra-55198 Botpress has just published a Make integration which should help you. https://app.botpress.cloud/hub/integrations/intver_01HNK62E0FPXXFX6TTBB668FJB
The body in the Webhook response module has to be structured in a specific way.
It is pretty easy to set up, but I don't have a tutorial on it yet. All you have to do is enter the Webhook, enable integration and then you should see the "Send Data" card in your bot.
g
I have tried it. But how do I receive the data from the sheet?
f
It comes in the output variable that you set
Hey, There was an issue with the Make integration that should be fixed now.
g
Hey thanks for the response. I actually tried using the Make integretation but it wasn't working. It's working fine now. Although the connection works great and Make receives the right variable, I can't get it to send back the relevant columns (product name, price, etc) even though the scenario seems to be setup correctly.
f
So you have problems storing the variable in Botpress?
g
Either Make is not sending back the data, or botpress isn't storing it. Please check the Make SS and see if it needs to be set up differently. Botpress shows no errors.
f
So I just recreated this, and I have done it a bit differently
Could return something like this
g
damn, thanks dude. This works perfectly.
the integration bugged out I think. I used "Run once" and went through the workflow again but make was still at "running". So I just used the following code to get around it.
await axios .post('https://hook.eu2.make.com/islujny85klphnug08u6jzhgggx84g', { finalItem: workflow.finalItem }) .then((response) => { workflow.productDetails = response.data // receive the incoming data in getDetails console.log('Success:', response.data) }) .catch((error) => { console.error('Error:', error) })
did it multiple times until I swapped out the integration with a code block
f
Thanks for the feedback. I am a bit unsure of what the bug is here?
Is it not sending anything to Make?
Or is it having problems getting the response
g
I think it just sometimes fails to send the response. When you hit "Run Once" on Make, it stops when it gets a response. It wasn't happening in my case today. So I tried tinkering with the settings, also tried deleting and reinstalling the integration with fresh API links.
Didn't work. So I used the code block instead. I do look forward to using the integretation in the future because it does make everything simpler.
f
I tried recreating it. Did you have it on to always be able to run?
Can also be set to on here
I had the same issue until this
I think that you can only have 2 set to always active with the free plan so keep that in mind
g
I always tap run once when setting something up. If it works, then I turn the scenario on.
I know this. I have only one active scenario.
I'll still check it once more when I'm home and let you know
Let me know if I'm doing something incorrectly here.
Also, make does not recognise my existing object productDetails, hence had to create a new one called proDetails as you can see in the video.
f
The things in Data in the Send Data card have to be JSON not just a string. I made the first tutorial about it here https://discord.com/channels/1108396290624213082/1217840226169262170
g
So I should convert the input variable into a JSON string before the Make module?
f
Yeah
7 Views