# Webhook

A webhook listens for incoming events on a specified endpoint and triggers the next step in the workflow upon receiving relevant data.

Webhooks listen for events from third-party apps.

They are commonly used for tasks like payment collection, where the chatbot waits for a payment processor to notify it once the payment is received.

![](/files/z7Ogt3YmDUlTyBAcfCXC)

### **Endpoint:**

Set this webhook endpoint in the application that will send the event.

When calling this endpoint, you must include the conversation\_key in the response payload. If it’s missing, the system will not consider the response successful.

You can extract the conversation\_key from the Conversation URL variable.

Before using the webhook block, add a JavaScript Action Block with the following code.

```json
const conversation_url = "Conversation URL";  
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 the webhook call for a set duration.

If the webhook is not triggered within this timeframe, the chat flow will continue through the **FAILURE** path.

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

#### **Response:**

When a webhook response is received, you can assign specific fields to variables for storage.

{% hint style="info" %}
&#x20;**You can map a maximum of 50 variables.**
{% endhint %}

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


---

# 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://help.reply.cx/action-blocks/webhook.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.
