# Instant Trigger

By setting Instant Trigger, it allows Integromat scenario to receive generated image immediately.

Stencil supports this feature out of the box and setting it up requires minimal effort. For now Instant Trigger support is scoped per template.

{% hint style="info" %}
Integromat's Instant Triggers execute the flow immediately after the remote server sends data. It is powered by webhooks.&#x20;
{% endhint %}

## Requirements

1. Instant Trigger's webhook URL
2. A working template in Stencil

## Recommended Approach

This approach scopes the Instant Trigger on template level. That means all images generated from this template will trigger Integromat Instant Trigger.

### 1. Set Trigger in scenario

![](https://1726200576-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MYeUDPAhozAcUAcc2Lr%2F-MeX-q2ITfEudmVy_LZA%2F-MeX0Cg9PsVU5d3AZcSe%2Fimage.png?alt=media\&token=911ced04-f7e3-45fe-a866-b5592d605703)

In your scenario editor, select Image Generated trigger from the list of available modules. This allows Integromat to listen for data coming from Stencil.

{% hint style="warning" %}
Instant Trigger must be the first module in scenario
{% endhint %}

### 2. Set up Trigger webhook

Add a new webhook or use existing webhook based on your need. Then copy the given webhook URL.

![](https://1726200576-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MYeUDPAhozAcUAcc2Lr%2F-MeX-q2ITfEudmVy_LZA%2F-MeX1lDLr5SOZfwx3iEW%2Fimage.jpg?alt=media\&token=3a5604ea-2c40-4fb0-ab19-6d35a3030279)

### 3. Set Trigger webhook in Stencil's Console

Go back to Stencil's webapp, select the template that you want to integrate with Integromat.

Then, go to its console and select Integromat under the Integrations tab.&#x20;

Paste the webhook URL from the previous step to the input box. Make sure your save your changes.

![Integromat integration section in Console](https://1726200576-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MYeUDPAhozAcUAcc2Lr%2F-MeX-q2ITfEudmVy_LZA%2F-MeX2oaFOg7vpiYU6UZ2%2Fimage.png?alt=media\&token=d9d18161-bc5b-46f2-9d95-75df99c0e309)

Congratulations! You have successfully set up your Integromat Instant Trigger. We've told you that it's going to be easy.

### 4. Test your changes (optional)

#### Test scenario

For testing purpose, I've setup my scenario to look like this. The trigger is linked to a `Get multiple variables` module (Integromat's tools module) and will capture two variables from the output of the trigger.

![](https://1726200576-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MYeUDPAhozAcUAcc2Lr%2F-MeX3aCc8KZzv14M5opk%2F-MeX4XQ9UiQGcG56Lw7V%2Fimage.png?alt=media\&token=fac669a3-d185-4380-b540-6e8945607556)

Once you've got that set up, run the scenario and it will start listening for data.

#### Sending data from Console

Go to your template's Console page that is linked to the trigger. Use the Test API tool to send a request to generate image.

![Sample request sent through Console](https://1726200576-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MYeUDPAhozAcUAcc2Lr%2F-MeX3aCc8KZzv14M5opk%2F-MeXXQ4vH1oQXA9rPBVG%2Fimage.png?alt=media\&token=42834980-afd3-4be1-8d68-284e61fda7c9)

If image is generated successfully, you should see similar output in your trigger module.

![Instant Trigger module successfully received data being sent from Stencil.](https://1726200576-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MYeUDPAhozAcUAcc2Lr%2F-MeX3aCc8KZzv14M5opk%2F-MeXWxps30CTd8PvcZ9g%2Fimage.png?alt=media\&token=fce4b938-611c-4bd8-a6d7-5e28632777b4)

### Alternative approach

The other approach to trigger instant trigger is by setting the `webhook_url` field with Integromat's Dedicated Instant Trigger webhook URL when generating the image.

{% tabs %}
{% tab title="POST <https://api.usestencil.com/images>" %}

```javascript
{
  "template": "68b168a8-17e8-4702-92fd-838c019bc3ec",
  "modifications": [
    {
      "name": "text_1",
      "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do..."
    }
  ],
  "webhook_url": "https://hook.integromat.com/2rxxxxxxxxxxxxxxxxxxxx"
}
```

{% endtab %}
{% endtabs %}

The downside of this approach is that you would have to set this each time you generate the image.
