This topic was automatically generated from Slack. You can find the original thread here.
I get a complex array of data from Hubspot and want to copy the data to a list to SendinBlue.
The basic structure for an email address looks like this:
{{steps.trigger.event.contact[“identity-profiles”][0].identities[0].value}}
but this way only one email address is copied not all of them
how must the array look like, that all email addresses are copied and not only one?
To copy all email addresses from the Hubspot data to a SendinBlue list, you’ll need to loop through the Hubspot data and extract the email addresses into an array. Then, you can use the SendinBlue action to add the contacts to a list. Here’s an example of how you can achieve this: import { axios } from "@pipedream/platform"; export default defineComponent({ async run({ steps, $ }) { // Extract email addresses from Hubspot data const contacts = steps.trigger.event.contacts; const emailAddresses = contacts.map(contact => contact["identity-profiles"][0].identities[0].value); // Use the SendinBlue Batch Create or Update Contact action to add the email addresses to a list await axios($, { method: "POST", url: "https://api.sendinblue.com/v3/contacts/import", headers: { "api-key": `${this.sendinblue.$auth.api_key}`, "content-type": "application/json", }, data: { emails: emailAddresses, listId: YOUR_LIST_ID, // Replace with your SendinBlue list ID }, }); }, }); Replace YOUR_LIST_ID with the ID of the SendinBlue list you want to add the contacts to. This code will loop through the Hubspot contacts, extract the email addresses, and add them to the specified SendinBlue list.
I apologize for the confusion earlier. It seems there was an issue with the import statement. Please use the following code to loop through the Hubspot contacts and extract the email addresses, then add them to the specified SendinBlue list: const contacts = steps.trigger.event.contacts; const emailAddresses = contacts.map( (contact) => contact["identity-profiles"][0].identities[0].value ); const sendinblueUrl = "https://api.sendinblue.com/v3/contacts/import"; const data = { emails: emailAddresses, listId: YOUR_LIST_ID, // Replace with your SendinBlue list ID }; await require("@pipedreamhq/platform").axios(this, { method: "POST", url: sendinblueUrl, headers: { "api-key": `${this.sendinblue.$auth.api_key}`, "content-type": "application/json", }, data, }); Replace YOUR_LIST_ID with the ID of the SendinBlue list you want to add the contacts to. This code will loop through the Hubspot contacts, extract the email addresses, and add them to the specified SendinBlue list.