# Calling Webhook

***

In this use case tutorial, we are going to create a custom tool that will be able to call a webhook endpoint, and pass in the necessary parameters into the webhook body. We'll be using [Make.com](https://www.make.com/en) to create the webhook workflow.

## Make

Head over to Make.com, after registering an account, create a workflow that has a Webhook module and Discord module, which looks like below:

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-8f78243b4a5dbd5eb546edb81928d8213f683f80%2Fscreely-1691756705932.png?alt=media" alt=""><figcaption></figcaption></figure>

From the Webhook module, you should be able to see a webhook URL:

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-a817d39dba471d21c9d4d37c733a659242e93912%2Fimage%20(46).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

From the Discord module, we are passing the `message` body from the Webhook as the message to send to Discord channel:

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-98ee4c120a783fd6312ce30ad4f6c871a9bb2d83%2Fimage%20(47).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

To test it out, you can click Run once at the bottom left corner, and send a POST request with a JSON body

```json
{
    "message": "Hello Discord!"
}
```

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-4f264640c8e6e79202f2366dc78c3a28ce502fe6%2Fimage%20(48).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

You'll be able to see a Discord message sent to the channel:

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-c57ce0db23f97057f2290b8e32ad28a4dc4911d5%2Fimage%20(49).png?alt=media" alt="" width="249"><figcaption></figcaption></figure>

Perfect! We have successfully configured a workflow that is able to pass a message and send to Discord channel [🎉 ](https://emojiterra.com/party-popper/)[🎉](https://emojiterra.com/party-popper/)

## Tailwinds

In Tailwinds, we are going to create a custom tool that is able to call the Webhook POST request, with the message body.

From the dashboard, click **Tools**, then click **Create**

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-f86ad79d452adc854137baadb5d2f16b67564b98%2Fscreely-1691758397783.png?alt=media" alt=""><figcaption></figcaption></figure>

We can then fill in the following fields (feel free to change this according to your needs):

* **Tool Name**: make\_webhook (must be in snake\_case)
* **Tool Description**: Useful when you need to send message to Discord
* **Input Schema**:

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-e902eef21dc089bcf38b11a8aea0fb188e366ef8%2Fimage%20(167).png?alt=media" alt=""><figcaption></figcaption></figure>

* **JavaScript Function**:

```javascript
const fetch = require('node-fetch');
const webhookUrl = 'https://hook.eu1.make.com/abcdef';
const body = {
	"message": $message
};
const options = {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify(body)
};
try {
    const response = await fetch(webhookUrl, options);
    const text = await response.text();
    return text;
} catch (error) {
    console.error(error);
    return '';
}
```

Click **Add** to save the custom tool, and you should be able to see it now:

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-8ab2351e70085c882452a7227ebb420fe2576b5e%2Fimage%20(51).png?alt=media" alt="" width="279"><figcaption></figcaption></figure>

Now, create a new canvas with following nodes:

* **Buffer Memory**
* **ChatOpenAI**
* **Custom Tool** (select the make\_webhook tool we just created)
* **OpenAI Function Agent**

It should looks like below after connecting them up:

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-b1a367fd5d953eb886261219b21fddcacbf41fb7%2Fscreely-1691758990676.png?alt=media" alt=""><figcaption></figcaption></figure>

Save the chatflow, and start testing it!

For example, we can ask question like *"how to cook an egg"*

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-4cb1b4a98278daeaaef49c474587d11158267f2f%2Fimage%20(52).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

Then ask the agent to send all of these to Discord:

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-98f95c279f33dcac01c0f3ed506a4210b00e8c34%2Fimage%20(53).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

Go to the Discord channel, and you will be able to see the message:

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-73793197f0e0e1a3a60543b3378b1a7e9738ab9a%2Fimage%20(54).png?alt=media" alt=""><figcaption></figcaption></figure>

That's it! OpenAI Function Agent will be able to automatically figure out what to pass as the message and send it over to Discord. This is just a quick example of how to trigger a webhook workflow with dynamic body. The same idea can be applied to workflow that has a webhook and Gmail, GoogleSheets etc.

You can read more on how to pass chat information like `sessionId`, `flowid` and `variables` to custom tool
