# Custom Webhooks

Most of the time, you can use the built-in Trigger blocks to invoke a workflow. But what if you want to trigger a Forge workflow when an event happens within your own app. In this scenario, it wouldn't make sense to use one of the pre-built triggers.

To get around this, we've baked in a custom webhook block. The webhook block can be customized with your company icon and name. In this example, my Forge account is called "Gregg's Org" so I'll search that in the trigger blocks list.

![](/files/1VM9m1hucGeV8SOjZDLX)

{% hint style="info" %}
If you want to customize the name and icon displayed in the custom webhook trigger block, navigate to Forge settings and upload your company name and icon there.
{% endhint %}

You'll be asked to select what type of authentication (if any) you want to use for the webhook. For the purposes of our demo we'll use **Unauthenticated** but you can easily specify authentication using an API Key.

![](/files/r5nE0pJueO7UrAlNrpiE)

Typically, when invoking a workflow, we oftentimes see SaaS Vendors wanting to send over dynamic values to whatever app they're trying to connect to. If that sounds like something you want to do, select the **Optional Parameters** dropdown and specify the JSON payload you want to pass along. Note that we only allow same-line JSON structures (i.e. no nested JSON objects).

Revisiting our previous example where we linked a Shopify store to Mailchimp, let's do the same thing here. In other words, let's assume you want to connect your app to Mailchimp so that every time an event happens in your app -> then a user is added to a Mailchimp list.

To do this, we'll want to pass over an email value to the webhook block. Then, we can dynamically access the `email` value in the Mailchimp block. Note that you **must** define the schema in the webhook block in order for Alloy Forge to know what data to map to.

![](/files/6Al4fdzXnw1DgHor7kkz)

Next, add a Mailchimp block and link the `email` value to the Mailchimp list like we did in the Shopify example before. And when you're done, activate the workflow to make it live.

![](/files/EOnRuhmrEQKdjdjSYryH)

### Invoking the Webhook

When using the Custom Webhook Trigger, like any other workflow in Forge, our system creates child workflows for every user who invokes this workflow. However, unlike other trigger blocks which are invoked by third party systems (i.e. Shopify Trigger, BigCommerce Trigger, etc), the Custom Webhook Trigger assumes **you** will invoke it via a **POST** request. Therefore, in order to invoke it properly, we need to make sure things are configured properly.

Recall the `childWorkflowId` value returned from the `Alloy.openWorkflowModal()` method we discussed above. As suggested above, you'll want to save this identifier in your database to access it later on. Note that this Id is only returned when the user authenticates the workflow in the Forge modal. To invoke a Forge workflow that uses a custom webhook trigger, make a POST request to `https://webhooks.runalloy.com/:childWorkflowId` where the `childWorkflowId` is the custom workflow Id generated by the `openWorkflowModal()` method.  This tells Forge *exactly* what child workflow to run. If your workflow uses custom expressions then make sure to pass them along as the body data.

Let's take a look at an example below:

```
axios.request({
  method: 'POST',
  url: `https://webhooks.runalloy.com/:childWorkflowId`,
  data: { <YOUR JSON BODY> }
});
```

If we were to invoke our Mailchimp example from above, we'd do something like the following:

```
axios.request({
  method: 'POST',
  url: `https://webhooks.runalloy.com/:childWorkflowId`,
  data: { "email": <your-dynamic-value> }
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gregg.gitbook.io/alloy-developer/custom-webhooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
