Skip to content

Zapier

This article guides you through the steps to send data from your system to your Seen Project.

This article assumes that you already have a published video within your Project. Read more about Projects in the Projects documentation.

  1. Create a Zapier account at https://zapier.com/.

  2. Select your Trigger. This is what connects any of your platforms to Zapier.

  3. In order to format a request and send it to Seen's API, select the Action called Code by Zapier, and create a custom code block to handle the request. This example uses JavaScript as the language.

  4. Add the input data fields from your Trigger step. (This example uses the fields "first_name" and "id".)

  5. Add additional input data fields for your Seen project endpoint and your Bearer token. This helps with the safety of the code as well as readability.

    You can find your project endpoint and create an API key in the Run tab of your project.

  6. Use the code snippet below as a starting point:

javascript
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();

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.

  1. You can now test the step and publish.