> ## Documentation Index
> Fetch the complete documentation index at: https://developer.voyado.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom triggers

Engage's automation functionality lets you create individual marketing journeys for every contact in your system. Purchases, birthdays and other events can act as triggers to start up automated flows based on a specific contact's data.

You can also set up your own custom triggers that can be used to manually start automations. For example, if you want to use some event in your POS that doesn't have a built-in trigger in Engage, a custom trigger is how you can do it.

## Setting up custom triggers

You can set up custom triggers yourself in Config Hub (the Engage configuration area).

<Card title="Read more about Config Hub" href="https://help.engage.voyado.com/hc/en-gb/sections/21844508239004-Configuring-Engage-via-Config-Hub" icon="https://mintcdn.com/voyado/Ns4bBcK3LNctK_Un/icons/developer-link.png?fit=max&auto=format&n=Ns4bBcK3LNctK_Un&q=85&s=fbd08f956358ab12f664a7158e1a1399" horizontal width="128" height="128" data-path="icons/developer-link.png" />

Once a custom trigger is set up, you can find it in Engage when you select "New automation". Here you can see the list of all the triggers available, with the standard ones located on top.

<Frame caption="The triggers available">
  <img src="https://mintcdn.com/voyado/jkdfo7eU3N-LsvyU/images/custom-trigger-01.png?fit=max&auto=format&n=jkdfo7eU3N-LsvyU&q=85&s=8a672da5fab7e7bdbc5b2127e4330ae8" alt="The triggers available" width="1187" height="621" data-path="images/custom-trigger-01.png" />
</Frame>

At the bottom of this list, you should find your custom trigger or triggers.

<Frame caption="Your custom triggers">
  <img src="https://mintcdn.com/voyado/jkdfo7eU3N-LsvyU/images/custom-trigger-02.png?fit=max&auto=format&n=jkdfo7eU3N-LsvyU&q=85&s=0d4e2407e32d57168601643d54d15154" alt="Your custom triggers" width="1156" height="623" data-path="images/custom-trigger-02.png" />
</Frame>

From this point on, your custom trigger can be handled like a standard one. Use it to create an automation, and create branches based on the incoming data.

Here is how a custom trigger automation looks:

<Frame caption="A custom trigger automation">
  <img src="https://mintcdn.com/voyado/jkdfo7eU3N-LsvyU/images/custom-trigger-03.png?fit=max&auto=format&n=jkdfo7eU3N-LsvyU&q=85&s=6f0802df761f485d4b143c3d2a656454" alt="A custom trigger automation" width="1762" height="946" data-path="images/custom-trigger-03.png" />
</Frame>

When this trigger is activated, contacts are moved into one of three branches, depending on a keyword found by a valuesplit ("Bike", "Ski" or everything else) and then sent an SMS. The number of contacts directed into each of the three branches can be seen, as well as the total number who triggered this automation.

The important points to remember about custom triggers are:

* They are called over the API using `triggerId` plus some identifier (`contactId` or another key)
* They can receive JSON data (data fields), the structure of which is defined per custom trigger

The data fields in your custom trigger can be used both for filtering in the automation and also as variable data in the content produced by the automation.

## Custom triggers and Design Studio

When working with Design Studio, you'll also need to define the JSON schema for the custom trigger so that it can be used. How you do that is described here:

<Card title="Learn about custom triggers" icon="https://mintcdn.com/voyado/Ns4bBcK3LNctK_Un/icons/help-center-link.png?fit=max&auto=format&n=Ns4bBcK3LNctK_Un&q=85&s=3e7ca2ce0b8cfb9fbd27a4bdf53b2ce1" horizontal href="https://help.engage.voyado.com/hc/en-gb/articles/23407506807068-Custom-triggers" width="128" height="128" data-path="icons/help-center-link.png" />

Important points:

* Your data source must be set to the `triggerId` in Design Studio
* Personalised fields in Design Studio can't be called unless defined in the custom trigger schema
* Customers cannot edit a custom trigger's schema in Config Hub once created - this can be done only by the project team and support
* Custom Triggers cannot be removed once created - this can be done only by the project team and support

You can read more here about data sources and personalized fields

<Card title="See about data sources & personalized fields" href="https://help.engage.voyado.com/hc/en-gb/articles/22281479196700-Data-sources-and-personalization-fields" icon="https://mintcdn.com/voyado/Ns4bBcK3LNctK_Un/icons/help-center-link.png?fit=max&auto=format&n=Ns4bBcK3LNctK_Un&q=85&s=3e7ca2ce0b8cfb9fbd27a4bdf53b2ce1" horizontal width="128" height="128" data-path="icons/help-center-link.png" />

## Using a custom trigger

In Engage, you can set up as many custom triggers as you want, as long as each `triggerId` is unique.

Some identifying value for the contact also needs to be sent (`contactId` or whatever is configured). The key used should be decided in collaboration with your Voyado team.

A custom trigger can only be triggered for an contact that exists in Engage.

There are a few ways to activate a custom trigger over the API, depending on what information you have:

```http If you know the contact ID theme={null}
POST /api/v3/automation/customTriggers/{triggerId}/triggerByContactId/{contactId}
```

```http If you know contact type and the key identifer value theme={null}
POST /api/v3/automation/customTriggers/{triggerId}/triggerByContactTypeAndKey/{contactType}/{keyValue}
```

```http If you know the external contact ID theme={null}
POST /api/v3/automation/customTriggers/{triggerId}/triggerByExternalContactId/{externalId}
```

```http If you know the personal identity number theme={null}
POST /api/v3/automation/customTriggers/{triggerId}/triggerBySocialSecurityNumber/{ssn}
```

### Examples of values

| Name        | Type   | Example value                        |
| ----------- | ------ | ------------------------------------ |
| triggerId   | String | aCustomTrigger                       |
| contactId   | GUID   | a67f201f-d86d-4ee2-bdc7-abce4444a804 |
| contactType | String | Member                               |
| keyValue    | String | mobilePhone                          |
| externalId  | String | 012345                               |
| ssn         | String | 198101010101                         |

## Payload example

Custom triggers are often used for transactional communication from the e-com or business layer to the end user. In these cases, a payload is often sent. Below is an example of the setup in the backend for a custom trigger that is used to populate a reset password email.

```json Custom trigger payload example theme={null}
{
    "oldAccount":"true" OR "false",
    "username":"[username]",
    "resetUrlHTML":"[http address of unique reset link]"
}
```

The value of the `oldAccount` flag can be used to filter different kinds of communication or trigger a specific automation. All automations using a certain trigger will listen for any responding API call but only the responding data sent in the payload will start the specific automation.
