> For the complete documentation index, see [llms.txt](https://docs.suvvy.ai/en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.suvvy.ai/en/channels/kastomnyi-kanal/rabota-s-vebkhukom.md).

# Working with webhook

{% hint style="info" %}
For testing webhook functionality, you can use [this service](https://webhook.site/)
{% endhint %}

To connect a custom channel, you need to specify the webhook to which Suvvy will send messages. It will send them in the following format:

## Request

{% hint style="danger" %}
Your webhook must return a status code between **200 and 299** and respond within **20 seconds**. Otherwise, the request will be considered failed, and the messages will be marked as undelivered *(such messages are not visible to Suvvy)*.
{% endhint %}

{% hint style="warning" %}
Your webhook will receive requests from **different IP addresses**. Use the **“Webhook Secret”** setting for verification and authorization.
{% endhint %}

{% hint style="warning" %}
Requests to your webhook will come from IP addresses located in the territory of the **Russian Federation.**
{% endhint %}

We will make a **POST** request to your webhook, passing a body in the following format:

```json
{
  "event_type": "new_messages",
  "new_messages": [
    {
      "type": "image",
      "message_sender": "ai",
      "file": {
        "name": "image.png",
        "url": "<direct link to the image>",
        "size_bytes": 10240,
        "mime_type": "image/png"
      }
    },
    {
      "type": "text",
      "message_sender": "ai",
      "text": "Hello! How can I help you?"
    }
  ]
}
```

If you specified a **webhook secret** during the custom channel connection, we will pass it in the `Authorization` header in the following format:

```
Bearer <your secret>
```

### Object in Request

| Field          | Type                                      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| -------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `event_type`   | string (`new_messages` or `test_request`) | <p><strong>Event type.</strong> Currently, only events for new messages and test requests are implemented, but others may be added in the future.</p><p></p><p>Depending on this parameter, the set of fields may change.</p><p><code>test\_request</code> - an event we will send to your webhook when you press the test button in Suvvy's control panel.</p><p></p><p>We recommend checking this parameter and ignoring the request if <code>event\_type != "new\_messages"</code>.</p> |
| `new_messages` | array of `Message` objects                | **New messages.** Present only if the event type is `new_messages`.                                                                                                                                                                                                                                                                                                                                                                                                                        |

#### `Message` Object

| Field            | Type                                          | Description                                                                                                                |
| ---------------- | --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `type`           | string (`text`, `image`, `audio`, `document`) | **Message type.** The set of fields depends on this parameter.                                                             |
| `message_sender` | string (`ai` or `employee`)                   | **Message sender.** Present in all types, determines who sent the message (bot or employee through Suvvy's control panel). |
| `text`           | string                                        | **Message text.** Present only if the message type is `text`.                                                              |
| `file`           | `MessageFile` object                          | **Attached file.** Present only if the message type is `image`, `audio`, or `document`.                                    |

#### `MessageFile` Object

| Field        | Type                                    | Description                                                                                                                                                                                                               |
| ------------ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `url`        | string                                  | <p><strong>Direct download link for the file.</strong></p><p></p><p>For example: <a href="https://i.imgur.com/ucYKBpa.png"><https://i.imgur.com/ucYKBpa.png></a></p><p></p><p>The file will be located on our server.</p> |
| `name`       | string                                  | **File name.**                                                                                                                                                                                                            |
| `size_bytes` | integer ∈ `[0, +∞)`                     | **File size in bytes.**                                                                                                                                                                                                   |
| `mime_type`  | string `^[a-zA-Z0-9]+/[a-zA-Z0-9-.+]+$` | **Mime-type of the file.**                                                                                                                                                                                                |

Suvvy can send files of the following types:

* For images: `image/png`, `image/jpeg`, `image/gif`
* For audio: `audio/ogg`, `audio/mpeg`, `audio/wav`, `audio/x-wav`, `audio/webm`, `audio/mp4`, `audio/m4a`, `audio/x-m4a`
* For documents: **any**, including the above-mentioned types


---

# 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://docs.suvvy.ai/en/channels/kastomnyi-kanal/rabota-s-vebkhukom.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.
