> For the complete documentation index, see [llms.txt](https://help.wotnot.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.wotnot.io/build/action-blocks/webhook.md).

# Webhook

{% hint style="info" %}
Available on the **PREMIUM** plan and above
{% endhint %}

Webhooks are used to listen to events occurring on a third-party app.&#x20;

It is most commonly used for use cases like payment collection, where the chatbot waits for the third-party payment processor to call the webhook once payment is received.

<figure><img src="/files/SsbuzygIKiCb32mHS94y" alt=""><figcaption></figcaption></figure>

## Endpoint

Set this webhook endpoint on the application that will publish the event.&#x20;

When invoking this endpoint, it is mandatory to return the `conversation_key` as part of the response payload; if it is not present, our systems will not consider it a successful response.

You can use the variable **Conversation URL** to extract the conversation\_key value from it.

Use a javascript action block before using the webhook block with this code.

```
const conversation_url = "Conversation URL";

// Function to extract the conversation key from the URL
function getLastPartOfUrl(url) {
    // Split the URL by slashes
    const parts = url.split('/');

    // Return the last part
    return parts[parts.length - 1];
}

// Retrieve the conversation key from the URL
const conversation_key = getLastPartOfUrl(conversation_url);

// Sets the conversation key into a new variable
wn.setConversationVariable("conversation_key", conversation_key);

// This variable will be used to push the conversation_key to the third-party app.
```

## Timeout

The chat flow will wait for this webhook call for the specified duration.&#x20;

If the webhook is not invoked in the given timeframe, the chat flow will proceed in the <mark style="background-color:red;">FAILURE</mark> flow.

{% hint style="info" %}
Set the duration between 1 and 300 seconds.
{% endhint %}

## Response

When a webhook response is received, you can map the fields that are to be saved into variables.&#x20;

{% hint style="info" %}
You can map a maximum of 50 variables.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://help.wotnot.io/build/action-blocks/webhook.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
