Triggering multiple webhooks with Zapier array of Json objects - arrays

I'm having trouble with triggering multiple webhooks via Zapier like explained on Zapiers website
Did anyone manage to use this functionality?
I'm trying to create "an array of properly formed JSON objects".
To be able to select it as data source in the next step it needs to be a simple array (thats why I stringify the jsons inside the array).
Here is the json array I'm creating in Zapier Code trying to use to trigger two separate webhooks being triggered
var jsonArray = ['{"id":1,"data":111}','{"id":2,"data":222}'];
output = {jsonArrayOut: jsonArray};
Here is a screenshot of a custom webhook request in Zapier
No matter how I format the data I always get one request, not two.
This is the result I see
Could anyone please tell me what am I missing?

Cool, so what you described in this comment should totally be possible.
Your zap will be the following:
Trigger - new email
Parse email, return an array of {id, data} (see below)
Update inventory (will happen for each item in the array in step 2)
This takes advantage of an undocumented feature of code steps where if they return arrays, the zap branches and subsequent steps run multiple times. Note that there's no UI for this and it'll look confusing, but it will work.
Your JS code will be something like the following:
// parse email code
// get items and their quantities
// return object that looks like this
return [{id: 1, data: 123}, {id: 2, data: 456}]
In step 3 (however you're doing that), you'll be able to select id and data as mappable inputs. When you're setting the zap up, you'll only see 1 and 123 as options, but when the zap is on and runs for real, step 3 will get run for each array element returned in step 2.

According to the docs:
You can send an array of properly formed JSON objects, and we will
trigger the Zap once for each object in the array.
Application will be able to parse through the json and understand its structure. Making it as a string makes it to lose it.
So I'm guessing sending it as a string might not work. The Application won't be able to find the number of elements inside the string, it will consider entire string to be one element.
Try,
output = [{"id": 1, "data": 111},{"id": 2, "data": 222}];

Related

How do i use this fetched data response?

I Am using react. I have a fetch setup in an useEffect to grab the data from a database from the backend. It pulls the account and sends it back to the front where i can access it from there.
From the File I want to access the user information i have a console log
I want to be able to grab like the firstname, lastname individually and use them in the script. how do i go about that. I did try to console log UserData.user and it gave me this result
However when i went to try to get firstname like userData.user.firstname i was met with an error. Im pretty new to react and pushing myself with things ive never done before to learn and any help would be great
Thank you everyone who does help it means alot
Please note all information in screenshots are fictitious and are just prop data.
EDIT:
This may be because you are trying to read the user information before the api returns the data. so check if the array has data before trying to access it . You can use save navigation to check for undefined or null
UserData.user[0]?.firstname
Based on your screenshot the data you are getting back is an array of user objects. To access it you will need to use:
userData.user[0].firstname
Note that this will access the first user object in the array - you will likely need checks to ensure the data data exists before accessing it, e.g.:
if (userData.user.length > 0) {
// Access data as needed
}
user is an array so you can acces like this
userData.user[0].firstname;
it will be better if you update your endPoint to get an object instead, so you can have access and check easier

Using ID's from previous request in new request

I have used Postman to extract a number of ID's from a request. Now I would like to use those ID's in a new series of requests using Postman. I can't figure out how to do this, does anyone know?
There are several hundreds of ID's and below are some examples that I can see in the console (but they do not appear in the request Body)
(100) [373894, 373893, 373467, 373459, 372712, …]
0: 373894
1: 373893
2: 373467
3: 373459
I would like to use postman to send new requests for all these ID's where I would like to fill the brackets with the ID's in the request URL that now looks like this:
https://app.rule.io/api/v2/campaigns/{{}}/statistics
I've tested the ID's one at a time and they work fine but I would like to run them all to then collect the data and send it to Google Data Studio. (background is that I'm trying to send campaign data from an e-mail marketing tool into Google Data Studio and combine it with website data)
Postman is able to run user-defined test scripts after the call performed. So you could define an array variable, add an ID each time you obtain it. And then, use that array variable to make a call with the whole bunch of IDs you have.
Take a look this blog: https://blog.postman.com/extracting-data-from-responses-and-chaining-requests/

How should I build a Fetch (Post) data array/structure from scratch? How do I join two arrays? Is it necessary for Fetch?

I need to build some kind of data structure/array starting with nothing and from a loop where the data is available. These would be key/value pairs. I tried initializing an empty cartData array [] in my javascript file, then using push, but this does not appear to be the right thing. This is a shopping cart program. I have all of the customer data captured in an array that looks like {First Name: firstName, Last Name: lastName, Email: emailAddress,... ,} and from the console it appears to have worked and in that form. For cartData, I'm getting something like
{Book_Title1: Price1},{Book_Title2: Price2},...{},{}
as a collection of objects. When I added to the cartData = [] array I gathered the data inside the loop and used the following method
cartData.push({[purchaseItem]: purchasePrice})
to add new items to the empty array. What I get is a collection of objects that look like
{BookTitle1: Price1}, {BookTitle2: Price2},...{}, {}
are the {}brackets unnecessary? There seem to be a number of opinions without examples. I was assuming that the first structure shown here is what is needed for Fetch to post the way a normally presents data. I could be wrong on that also. I need to know the correct way to do it and a way to combine the two data sets (three if we count the Key/Value pair for grand $total.) My goal is to have the customer hit the purchase button, the cart/form data to go to Formspree.io and for them to send an email with all of this order information. It works well enough with an unadulterated . I just need to amend the data for the cart.
It would help if you provide a snippet of the code that you've written, because it's not really clear what format are you sending the data in.
Your question seems to imply that you're sending the request body as an array. That is incorrect. It has to be a JSON.
Secondly make sure you add the 'Content-Type: application/json' header to your request

How to get the number (length) of slot values for Alexa skill

I am trying to generate a random response for my Alexa Skill. I have set it up as:
Intent = myIntent
Slot = mySlot
Slot Type = mySlotType
Slot Values = {A,B,C,D} //the ids are unique numbers 1 - 4
when the user says a word such as A it uses this to create a response. Now I want to add a case for 'random'.
So Slot Values = {random,A,B,C,D}. //ID for random is 0
When the user says random, I want to randomly choose from the other Slot Values and use this to create a response.
Can Slot Value ID be used to return the Slot Value value?
Anybody know a good way to do this? I am a novice so excuse any obvious oversights.
This might be a workaround for your problem. You can get the JSON structure of your interaction model and use it as a constant in your lambda index.js file. I usually use this official tool for generating backend code for my skill
:
https://s3.amazonaws.com/webappvui/skillcode/v2/index.html.
When you'll generate the code through this tool, you'll see that the code generated also has the whole interaction model used as constant. Since you will have the whole JSON schema of the interaction model at your disposal, you can perform any action on it.
Note: If you don't know where to get JSON schema of your interaction model, scroll down on the build tab of your skill on the developer console, you'll find a menu of JSON editor on the left navigation. It will give you the JSON schema of your interaction model.
You can use mySlot as optional value in the intent description. For example you can add few utterances without slot inside them. And on the backend side you can check is the slot filled. If it is not filled you can generate random answer.

How do i get my id field to show up in the request data when updating multiple records?

Datasource: Array source (Open source code)
I have a __getTable method that loads the data from a configuration file to an array that looks like this:
I created a method that takes in data in this form and creates a table out of it. The table creates a column in the row for every field present in the given data array except for id. id is a hidden field and the code generated by the input function looks like this:
but shows up like this when inspecting the code in firebug:
Ignore all except for what is in the control-group division.
Since im using the array source, i create my own update method and have to call updateAll() in my controller to call the method. All the data i need is in the request data except for the id! why, and how can i fix this? It looks like this:
The rest of the information on here might not be necessary but ill post it just in case.
I found the problem. Most of it was unique to my code though. There was a bug where i call the $this->Widget->input function. I use index rather than the id and that screws up my tabs. each data array passed in to the function had indexs from 0-~11 and so the values were overriding each other since the submit was for multiple tabs. Also i have a function 'open' that opens a table and the rows were specified to have 4 columns rather than 5 and id was the 5th column.

Resources