Webhook - Multiple Variables
I saw a few other posts that touched on this, but was not quite clear on if this is something natively built into Typebot. I am pulling data from a webhook that looks like this.
I want to be able to list each occurrence of "name" along with a link to the "url". There could be as many as 25 objects returned.
13 Replies
When you test your webhook request, you can then save the response to a variable and the data drop-down should help you select the right syntax, it should look like:
data.flatMap(item => item.json.articles.flatMap(item => item.name))
This is for Names
You can do the same for URLs
Check out the Movies recommendation template for reference
Thanks @Baptiste. When I did this in my testing and used the saved variable, {{name}} for example, it would only output one item in the text bubble. I've worked around it for now using javascript, but I'm not entirely sure what I'm missing.
Here's a flow that hits a webhook that returns this fake data. When I select data.data.flatMap(item => item.name) as the variable {{names}} and then output that in a text bubble, only the last name is provided. (Video of flow here: https://share.cleanshot.com/r69Q4q8c)
On a typebot v6, if you display a list variable in a text bubble, it will show only the last item.
I've introduced typebot v7 that removes that behavior (more info: https://docs.typebot.io/breaking-changes)
You should upgrade your app to v2.19.1
Ok, did the upgrade. I see now it's returning an array as such:
["Jennifer Smith","Jennifer Jones"]
How do I get the text bubble to treat that as individual rows of data? Or should I still be using javascript to accomplish that? Cheers.
You'd like to display the first or the last item?
All items.
Formatted as rows. So:
Jennifer Smith
Jennifer Jones
And eventually that data will include URLs so I'd like them formatted as markdown links. Already able to do this via javascript, but it's just a bit of a pain when adding new endpoints/data.
You need to do it in a Set variable block. I can help with the code if you need?
If you have time. I have some code already, but not sure it's very clean.
to have it as a list of bullet points:
'- ' + {{My list}}.join('\n- ')
That is embarrassingly simple. 😂 Thank you!
😂
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View