<aside>
This article guides you through the steps to send data from your system to you Seen Project.
This article assumes that you already have a published video within your Project.
Read more about Projects in our documentation.
</aside>
Create a Zapier account here: https://zapier.com/
Firstly, select your Trigger. This is what connects any of your platforms to Zapier.
In order to format a request and send to SEENs API, you need to select the Action called “Code by Zapier”, and create a custom code block to handle the request. In this example we use JavaScript as the language.
Add the input data fields from your Trigger step.
<aside>
This example uses the fields “first_name” and “id”.
</aside>
Add additional input data fields for your Seen project endpoint and your Bearer token. This helps with safety of the code as well as readability.
<aside>
You can find your project endpoint and create an API key in the Run tab of your project.
</aside>
You can use the below code snippet as a starting point:
const endpointUrl = inputData.endpoint_url || '';
const bearerToken = inputData.bearer_token || '';
const firstName = inputData.first_name || '';
const id = inputData.id || '';
if (!endpointUrl) throw new Error('Missing endpoint_url');
if (!bearerToken) throw new Error('Missing bearer_token');
const payload = {
first_name: firstName,
id: id
};
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 8000);
const response = await fetch(endpointUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${bearerToken}`,
},
body: JSON.stringify(payload),
signal: controller.signal,
});
clearTimeout(timeout);
if (!response.ok) {
let errorMessage = `API error ${response.status}`;
try {
const errorData = await response.json();
errorMessage = `${errorMessage}: ${JSON.stringify(errorData)}`;
} catch (e) {
const errorText = await response.text();
if (errorText) errorMessage = `${errorMessage}: ${errorText}`;
}
throw new Error(errorMessage);
}
return await response.json();
<aside>
Make sure to include all needed personalisation fields for your project.
The property keys of your payload need to match the personalisation fields within your project.
</aside>
You can now test the step and publish.