# How can we help?

## Overview

This article describes how to trigger email sends for Tealium AudienceStream audiences using Cordial's custom webhook. You can also [trigger email sends using the Cordial Connector within Tealium](https://support.cordial.com/hc/en-us/articles/14542336819341).

Before you get started, we recommend that you work out your use cases, including conditions that could cause the send to get canceled.

## Before opening Tealium

1. You need to first create an API key in Cordial for the Tealium calls to use.
   
   - [Learn how to set up a new API key here](https://support.cordial.com/hc/en-us/articles/115005365087).
   - [Visit this page to get the IPs Tealium will use](https://docs.tealium.com/server-side/administration/ip-allow-list/).

2. Your finished API key should look something like this:

## Add the Connector

1. Open the Tealium AudienceStream Marketplace and locate the audience Connectors. Click **Add Connector** and search for the webhook.

2. Select the **Audience** that will drive this connection. You can also set the trigger and specify any frequency caps that you apply via Tealium.

3. You have the option to select an existing action or create a new one. For our purposes, choose **Add Connector**. After naming your connector, enter the API key into the **Basic Authentication: Username** field.

4. Name the action and select **Send Customized Data via HTTP Request (Advanced)**.

5. This unlocks further configurations. Since we want to trigger an email automation in Cordial, select the **POST** method.

6. For the URL, use: https://api.cordial.io/v2/automationtemplates/{template key}/send.

Your template is the key value for the email automation you're trying to trigger. It can be found by clicking into your email automation in Cordial: **Message Automations > Email Automations**.

7. Add a header of **Content-Type** and set **Map** to application/JSON.

8. Set the body content type to application/JSON as well. Then in the **Body Data** section, map your template (defined later) to **Body**. In this example, the template is named cordial_send.

Make sure to select **Body** from the **To:** dropdown menu. If you manually type in Body, your webhook will not work.

9. Open **Template Variables** and map all the data from Tealium to variable names that will be used in your template. Make sure to include a variable that can be used for finding the contact, like email address.

## Set up the template

1. Your template needs to mimic the API send you would initiate for this action. So the **To:** section determines who will receive the email. You can use email or cID, depending on which one Tealium has captured.

2. All the other variables will go into **extVars** and will be available in the **$extVars** object in your message. The variables on the left side will be the names Cordial receives.

You should not use a naming convention that uses a dot in the name. It's better to use underscores.

3. The variable name on the right needs to have the {{ and match the name in the mapping above.

4. The final **identifyBy** should match the variable you're passing in the **To:** section.

5. To test this setup, you can use Tealium's Trace utility to browse the site, ensure you get all the variables set, and then end your session to see if you successfully trigger an email.
