### Webhook Template Filling Guide Source: https://www.pachca.com/articles/kak-pravilno-zapolnit-shablon-webhook This guide explains how to correctly fill out a Webhook template in Pachca. It covers syntax, variables, and provides examples for setting up integrations. It details the use of Mustache and Liquid templating languages for dynamic content. ```json { "@context": "https://schema.org", "@type": "HowTo", "name": "Как правильно заполнить шаблон Webhook", "description": "Как правильно заполнить шаблон Webhook в Пачке: синтаксис, переменные и примеры настройки", "image": { "@type": "ImageObject", "url": "https://pachca.com/help/kak-pravilno-zapolnit-shablon-webhook.png" }, "step": [ { "@type": "HowToStep", "position": 1, "name": "Откуда брать поля для заполнения шаблона", "text": "Для того чтобы узнать, какие поля указывать в шаблоне, нужно посмотреть структуру JSON запроса, которая приходит от стороннего сервиса. Для этого можно воспользоваться специальным сервисом для создани" }, { "@type": "HowToStep", "position": 2, "name": "Mustache —", "text": "это простой синтаксис шаблонов, без логических операторов. Его можно использовать для простых ботов, которые будут присылать события из стороннего сервиса в одном формате. Например, сообщение о новой " }, { "@type": "HowToStep", "position": 3, "name": "Синтаксис Mustache", "text": "В шаблоне Mustache все поля заключаются в двойные скобки `{{name}}` JSON запрос: ```json { "name": "Roman", "age": 10 } ``` Mustache шаблон: ``` Привет, {{name}}! ``` Сообщение от бота: ``` Прив" }, { "@type": "HowToStep", "position": 4, "name": "Пример Mustache шаблона:", "text": "JSON: ```json { "user": { "id": "12345", "userName": "Vadim Grushev" }, "issue": { "id": "10000", "fields": { "title": "Очень важная задача", "description": "Что-то что нужно сделать срочно", "project" } } } ```" }, { "@type": "HowToStep", "position": 5, "name": "Liquid —", "text": "это язык шаблонов, который позволяет создать единый шаблон и динамически его изменять. В отличие от Mustache, позволяет использовать логические операторы if, else и тд. Например, с его помощью, можно " }, { "@type": "HowToStep", "position": 6, "name": "Синтаксис Liquid", "text": "Объекты — представляют из себя структуру данных, описывающую поля из JSON. Для доступа к объектам и их свойствам используются двойные фигурные скобки `{{ object.field }}` JSON запрос: ```json { "application": { "id": "12345", "name": "Заявка на таблицу сравнения", "contact": { "number": "+799999999999", "call": true } } } ```" }, { "@type": "HowToStep", "position": 7, "name": "Пример Liquid шаблона:", "text": "JSON запрос: ```json { "application": { "id": "12345", "name": "Заявка на таблицу сравнения", "contact": { "number": "+799999999999", "call": true } } } ``` Liquid шаблон: ``` {% assign Source = appli" } ] } ``` -------------------------------- ### Example Request for Multiple Link Previews (JSON) Source: https://www.pachca.com/articles/unfurling-ssylok-v-pachce This JSON example demonstrates how to structure a request to the Pachca API to generate previews for multiple links simultaneously. It includes fields for title, description, and image URLs or file references. ```json { "link_previews": { "https://example.com/page1": { "title": "Заголовок страницы 1", "description": "Описание страницы 1", "image_url": "https://example.com/image1.jpg" }, "https://subdomain.example.org/page2": { "title": "Заголовок страницы 2", "description": "Описание страницы 2", "image": { "key": "путь/к/файлу/изображения2.jpg", "name": "изображение2.jpg", "size": 12345 } } } } ``` -------------------------------- ### Complex Liquid Templating Example Source: https://www.pachca.com/articles/kak-pravilno-zapolnit-shablon-webhook A comprehensive Liquid template example demonstrating conditional logic based on string content and boolean values to customize application-related messages. ```json { "application": { "id": "12345", "name": "Заявка на таблицу сравнения", "contact": { "number": "+799999999999", "call": true } } } ``` ```liquid {% assign Source = application.name%} {% if Source contains 'демо' %} {% assign heading = "**Новая заявка на демонстрацию**" %} {% elseif Source contains 'таблицу' %} {% assign heading = "**Новая заявка на таблицу**" %} {% endif %} {{heading}} {% if application.contact.call == true %} "Связаться по телефону:" {% else %} "Написать в мессенджер:" {% endif %} {{application.contact.number}} ``` -------------------------------- ### Webhook Integration Setup Source: https://www.pachca.com/articles/webhook This section details how to set up a Webhook integration within the platform. It covers finding the integration, adding it, and configuring basic bot settings. ```APIDOC ## Webhook Integration Setup ### Description Guides users through finding and adding the Webhook integration from the integration showcase and configuring essential bot parameters. ### Method N/A (UI-driven setup) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Example Outgoing Webhook Request (HTTP) Source: https://dev.pachca.com/guides/webhook Demonstrates an example HTTP POST request for an outgoing webhook, specifically for a new message event. It includes necessary headers like `host`, `content-Type`, and `pachca-signature`, along with the JSON payload. ```http POST https://yourweb.site/read HTTP/1.1 host: yourweb.site content-Type: application/json pachca-signature: a805d3470c263f4628cafc4ed66235d8fe2229891d1fcf4e400331adff5d8e5a user-agent: Faraday v2.12.2 content-length: 358 { "event": "new", "type": "message", "webhook_timestamp": 1744618734, "chat_id": 918264, "content": "Клиент просит поправить шапку, подробности в документе", "user_id": 134412, "id": 56431, "created_at": "2025-04-14T08:18:54.000Z", "parent_message_id": null, "entity_type": "discussion", "entity_id": 918264, "thread": null, "url": "https://app.pachca.com/chats/124511?message=56431" } ``` -------------------------------- ### Mustache Templating Example for Webhooks Source: https://www.pachca.com/articles/kak-pravilno-zapolnit-shablon-webhook Provides a more complex example of Mustache templating with nested JSON objects. It shows how to access fields within nested structures using dot notation. ```json { "user": { "id": "12345", "userName": "Vadim Grushev" }, "issue": { "id": "10000", "fields": { "title": "Очень важная задача", "description": "Что-то что нужно сделать срочно", "project" } } } ``` -------------------------------- ### Liquid Filter Example Source: https://www.pachca.com/articles/kak-pravilno-zapolnit-shablon-webhook Shows how to use filters in Liquid to modify the output of variables. This example converts a string to lowercase using the 'downcase' filter. ```liquid {{ "CALM DOWN!" | downcase }} ``` -------------------------------- ### Mustache Templating Example Source: https://www.pachca.com/articles/kak-pravilno-zapolnit-shablon-webhook Demonstrates how to use Mustache templates with JSON data to render dynamic content. It shows how to access nested properties and display user and issue details. ```json { "user": { "id": "12345", "userName": "Vadim Grushev" }, "issue": { "id": "10000", "fields": { "title": "Очень важная задача", "description": "Что-то что нужно сделать срочно", "project": { "name": "Pachca" } } } } ``` ```mustache Новое событие в проекте {{#issue}}{{#fields}}{{#project}}**{{name}}**{{/project}}{{/fields}}{{/issue}} {{#user}}**{{userName}}**{{/user}} **Название задачи** {{#issue}}{{#fields}}{{title}}{{/fields}}{{/issue}} **Описание задачи** {{#issue}}{{#fields}}{{description}}{{/fields}}{{/issue}} ``` -------------------------------- ### Mustache Template Example with Nested Data and Formatting Source: https://www.pachca.com/articles/kak-pravilno-zapolnit-shablon-webhook A comprehensive example showcasing a Mustache template applied to a complex JSON structure. It demonstrates accessing deeply nested fields and applying basic formatting like bold text. ```json { "user": { "id": "12345", "userName": "Vadim Grushev" }, "issue": { "id": "10000", "fields": { "title": "Очень важная задача", "description": "Что-то что нужно сделать срочно", "project": { "name": "Pachca" } } } } ``` ```mustache Новое событие в проекте {{#issue}}{{#fields}}{{#project}}**{{name}}**{{/project}}{{/fields}}{{/issue}} {{#user}}**{{userName}}**{{/user}} **Название задачи** {{#issue}}{{#fields}}{{title}}{{/fields}}{{/issue}} **Описание задачи** {{#issue}}{{#fields}}{{description}}{{/fields}}{{/issue}} ``` ```text Новое событие в проекте **Pachca** **Vadim Grushev** **Название задачи** Очень важная задача **Описание задачи** Что-то что нужно сделать срочно ``` -------------------------------- ### Liquid Object Access Example Source: https://www.pachca.com/articles/kak-pravilno-zapolnit-shablon-webhook Illustrates basic object access in Liquid templating. It shows how to retrieve nested properties from a JSON object using double curly braces. ```json { "student": { "requisites": { "name": "Anton" } } } ``` ```liquid {{student.requisites.name}} ``` -------------------------------- ### Get Message Info API Call (Conceptual) Source: https://www.pachca.com/articles/knopki-v-chat-botah This is a conceptual example of how to retrieve information about a message using the Pachca API. This is useful for obtaining the chat ID to send follow-up messages. ```javascript // Conceptual example of getting message info via API // Replace with actual API endpoint and payload structure fetch('https://dev.pachca.com/messages/get/?message_id=21344124', { method: 'GET', headers: { 'Authorization': 'Bearer YOUR_API_TOKEN' } }) .then(response => response.json()) .then(data => { const chatId = data.chat_id; // Now you can use chatId to send a new message // e.g., sendMessage(chatId, 'New message content'); }); ``` -------------------------------- ### Rule Example 2: Passport Data Block Source: https://dev.pachca.com/guides/dlp An example of a rule that blocks messages containing passport data, using both keyword and regex conditions. ```APIDOC ## POST /rules/example2 ### Description This endpoint provides an example of a rule that blocks messages containing passport data. It uses a combination of a keyword check for 'паспорт' and a regular expression to match passport number formats. ### Method POST ### Endpoint /rules/example2 ### Request Body ```json { "conditions": { "all": [ { "type": "keyword", "value": "паспорт" }, { "type": "regex", "pattern": "\\b\\d{4}\\s?\\d{6}\\b" } ] }, "action": { "type": "BLOCK", "message": "Нельзя отправлять паспортные данные" } } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### POST /api/link_previews Source: https://dev.pachca.com/link-previews/add-link-previews Creates a new link preview. You can provide a title, description, and either an image URL or upload an image. ```APIDOC ## POST /api/link_previews ### Description Creates a new link preview with specified details. ### Method POST ### Endpoint /api/link_previews ### Parameters #### Request Body - **title** (string) - Optional - The title of the link preview. - **description** (string) - Optional - The description of the link preview. - **image_url** (string) - Optional - A public URL for the preview image. - **image** (object) - Optional - An object containing image details for upload. - **key** (string) - Required - The key of the image obtained from the file upload API. - **name** (string) - Required - The name of the image file, including its extension. ### Request Example ```json { "title": "Article: Sending Files", "description": "Example of sending files to a remote server", "image_url": "https://website.com/img/landing.png" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the created link preview. - **title** (string) - The title of the link preview. - **description** (string) - The description of the link preview. - **image_url** (string) - The public URL of the preview image. #### Response Example ```json { "id": "preview-12345", "title": "Article: Sending Files", "description": "Example of sending files to a remote server", "image_url": "https://website.com/img/landing.png" } ``` ``` -------------------------------- ### POST /messages/{id}/link_previews Source: https://dev.pachca.com/link-previews/add-link-previews Creates link previews for a given message. You need to provide the message ID in the URL. You can supply image URLs or upload images directly. If both are provided, the uploaded image takes precedence. The request will fail if any of the provided URLs are invalid or not configured for the bot. ```APIDOC ## POST /messages/{id}/link_previews ### Description Creates link previews for a given message. You need to provide the message ID in the URL. You can supply image URLs or upload images directly. If both are provided, the uploaded image takes precedence. The request will fail if any of the provided URLs are invalid or not configured for the bot. ### Method POST ### Endpoint /messages/{id}/link_previews ### Parameters #### Path Parameters - **id** (integer) - Required - Идентификатор сообщения #### Query Parameters *None* #### Request Body - **image_url** (string) - Optional - Public URL of the image to be used in the preview. - **image** (file) - Optional - Direct upload of the image file. - **urls** (array of strings) - Required - List of URLs to unfurl. ### Request Example ```json { "image_url": "https://example.com/image.jpg", "urls": [ "https://example.com/article1", "https://example.com/article2" ] } ``` ### Response #### Success Response (204) - The response body will be empty upon successful execution. #### Response Example *No response body* #### Error Response (400) - **errors** (object) - Contains details about the validation errors. ```json { "errors": { "field_name": "error message" } } ``` ``` -------------------------------- ### Rule Example 1: Phone Number Detection Source: https://dev.pachca.com/guides/dlp An example of a rule that uses a regular expression to detect phone numbers and logs an audit message. ```APIDOC ## POST /rules/example1 ### Description This endpoint provides an example of a rule designed to detect phone numbers within a message using a regular expression. If a phone number is detected, an audit log message is generated. ### Method POST ### Endpoint /rules/example1 ### Request Body ```json { "conditions": { "any": [ { "type": "regex", "pattern": "\\b(?:\\+7|7|8)\\s*\\(?\\d{3}\\)?\\s*\\d{3}[\\s-]*\\d{2}[\\s-]*\\d{2}\\b" } ] }, "action": { "type": "AUDIT_LOG", "message": "Обнаружен номер телефона в сообщении" } } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### POST /link-previews Source: https://dev.pachca.com/link-previews/add-link-previews Creates link previews for a given set of URLs. The request body should contain a JSON object where keys are URLs and values are preview data. ```APIDOC ## POST /link-previews ### Description Creates link previews for a given set of URLs. The request body should contain a JSON object where keys are URLs and values are preview data. ### Method POST ### Endpoint /link-previews ### Parameters #### Request Body - **link_previews** (object) - Required - A JSON map of link previews, where each key is a URL and the value is the preview data. - **additionalProperties** (object) - Description for additional properties of the preview data. ### Request Example ```json { "link_previews": { "https://example.com": { "title": "Example Domain", "description": "This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.", "image": "https://example.com/image.jpg" } } } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the operation. - **message** (string) - A message describing the result of the operation. #### Response Example ```json { "status": "success", "message": "Link previews generated successfully." } ``` #### Error Response (400) - **errors** (array) - A list of error objects. - **code** (string) - Error code. - **payload** (string) - Additional error details. #### Error Response Example ```json { "errors": [ { "code": "INVALID_URL", "payload": "https://invalid-url" } ] } ``` ``` -------------------------------- ### Theme Management Script (JavaScript) Source: https://dev.pachca.com/guides/dlp Этот скрипт управляет темой веб-интерфейса, используя localStorage для сохранения предпочтений пользователя и media query для определения системных настроек. Он добавляет классы 'light' или 'dark' к элементу document.documentElement. ```javascript (function() { try { var savedTheme = localStorage.getItem('theme'); var html = document.documentElement; var systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches; html.classList.remove('dark', 'light'); if (savedTheme === 'light') { html.classList.add('light'); } else if (savedTheme === 'dark' || systemDark) { html.classList.add('dark'); } } catch (e) {} })(); ``` -------------------------------- ### Initialize Yandex Metrika Tracking (JavaScript) Source: https://pachca.com/blog/kak-podklyuchit-lyubimye-servisy-k-pachke This JavaScript code snippet initializes the Yandex Metrika web analytics service. It includes the necessary function calls to set up tracking, enable webvisor for session recording, clickmap, accurate bounce tracking, and link tracking. This script should be included in the page's head or before the closing body tag for proper functionality. ```javascript (function(m,e,t,r,i,k,a){ m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)}; m[i].l=1*new Date(); for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }} k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a) })(window, document,'script','https://mc.yandex.ru/metrika/tag.js', 'ym'); ym(57008725, 'init', {webvisor:true, clickmap:true, accurateTrackBounce:true, trackLinks:true}); ``` -------------------------------- ### Unfurl Bot Webhook Example Source: https://www.pachca.com/articles/unfurling-ssylok-v-pachce An example JSON payload representing a webhook triggered by a message containing links to specified domains. It includes event type, chat ID, timestamp, and a list of matched links with their URLs and domains. ```json { "type": "message", "event": "link_shared", "chat_id": 23438, "created_at": "2024-09-18T19:53:14.000Z", "message_id": 268092, "links": [ { "url": "https://example.com/page1", "domain": "example.com" }, { "url": "https://subdomain.example.org/page2", "domain": "example.org" } ] } ``` -------------------------------- ### POST /link-previews/add-link-previews Source: https://dev.pachca.com/link-previews/add-link-previews Creates link previews for a given message. You can provide image URLs or upload images directly. The API supports unfurling links via a specific bot access token. ```APIDOC ## POST /link-previews/add-link-previews ### Description Creates link previews for messages. Requires the message ID and can accept image URLs or direct file uploads. This endpoint is accessible only via the unfurl bot. ### Method POST ### Endpoint /link-previews/add-link-previews ### Parameters #### Query Parameters - **id** (string) - Required - The ID of the message for which to create link previews. #### Request Body - **link_previews** (array) - Required - An array of link preview objects. - **url** (string) - Required - The URL to unfurl. - **image_url** (string) - Optional - A public URL for the image to use in the preview. - **image** (file) - Optional - A file to upload for the image. Takes precedence over `image_url` if both are provided. ### Request Example ```json { "link_previews": [ { "url": "https://example.com", "image_url": "https://example.com/image.jpg" }, { "url": "https://another-example.com", "image": "@/path/to/your/image.png" } ] } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success status of the operation. - **message** (string) - A confirmation message. #### Response Example ```json { "status": "success", "message": "Link previews created successfully." } ``` ### Error Handling - **400 Bad Request**: If required parameters are missing or invalid. - **401 Unauthorized**: If the access token is invalid or insufficient. - **500 Internal Server Error**: If there was a server-side issue. ``` -------------------------------- ### GET /llmstxt/dev_pachca_llms-full_txt Source: https://dev.pachca.com/messages/list Retrieves a list of messages with support for pagination and sorting. ```APIDOC ## GET /llmstxt/dev_pachca_llms-full_txt ### Description Retrieves a list of messages. Supports filtering by `limit` and `page` for pagination, and `sort[field]` for ordering. ### Method GET ### Endpoint /llmstxt/dev_pachca_llms-full_txt ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of items to return. Defaults to 25. Minimum value is 1, maximum is 50. - **page** (integer) - Optional - The page number to retrieve. Defaults to 1. - **sort[field]** (string) - Optional - Composite sort parameter. Currently supports sorting by `id`. ### Response #### Success Response (200) - **data** (array) - An array of message objects. #### Response Example ```json { "data": [ { "id": "message_id_1", "content": "This is the first message.", "timestamp": "2023-10-27T10:00:00Z" }, { "id": "message_id_2", "content": "This is the second message.", "timestamp": "2023-10-27T10:05:00Z" } ] } ``` ``` -------------------------------- ### POST /messages/{id}/link_previews Source: https://dev.pachca.com/link-previews/add-link-previews This endpoint creates link previews for a given message. You need to provide the message ID and a list of URLs for which to generate previews. Image URLs or uploaded images can be included. ```APIDOC ## POST /messages/{id}/link_previews ### Description Creates link previews for a message. Requires the message ID and a list of URLs. Image URLs or uploaded images can be provided. ### Method POST ### Endpoint /messages/{id}/link_previews ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the message to which the link previews will be added. #### Query Parameters None #### Request Body - **link_previews** (array) - Required - An array of objects, where each object contains information about a link preview. - **url** (string) - Required - The URL for which to generate a preview. - **image_url** (string) - Optional - A public URL for an image to be displayed with the preview. - **image** (file) - Optional - An image file to be uploaded and displayed with the preview. This parameter has higher priority than `image_url`. ### Request Example ```json { "link_previews": [ { "url": "https://example.com", "image_url": "https://example.com/image.jpg" } ] } ``` ### Response #### Success Response (200) - **message_id** (string) - The ID of the message with the created link previews. - **link_previews** (array) - An array of created link preview objects. - **url** (string) - The original URL. - **title** (string) - The title of the previewed page. - **description** (string) - The description of the previewed page. - **image** (string) - The URL of the image used in the preview. #### Response Example ```json { "message_id": "msg_12345", "link_previews": [ { "url": "https://example.com", "title": "Example Domain", "description": "This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.", "image": "https://example.com/image.jpg" } ] } ``` ### Error Handling - If any URL in `link_previews` is invalid or not associated with the message, or if the domain is not configured for the bot, the request will not be processed, and no previews will be created. - Currently, only the first link preview created for a message is displayed. All provided `link_previews` will be saved for future updates. ``` -------------------------------- ### GET /messages Source: https://dev.pachca.com/messages/list Retrieves a list of messages. This endpoint supports filtering and sorting. ```APIDOC ## GET /messages ### Description Retrieves a list of messages. This endpoint supports filtering and sorting. ### Method GET ### Endpoint /messages ### Parameters #### Query Parameters - **entity_type** (string) - Optional - The type of entity to filter messages by (e.g., 'discussion', 'thread', 'user'). - **entity_id** (integer) - Optional - The ID of the entity to filter messages by. - **sort_order** (string) - Optional - The order in which to sort the messages (e.g., 'asc', 'desc'). ### Request Example ```json { "example": "GET /messages?entity_type=discussion&entity_id=123&sort_order=desc" } ``` ### Response #### Success Response (200) - **data** (array) - An array of message objects. - **id** (integer) - The unique identifier of the message. - **entity_type** (string) - The type of entity the message is associated with. - **entity_id** (integer) - The ID of the entity the message is associated with. - **chat_id** (integer) - The ID of the chat the message belongs to. - **content** (string) - The content of the message. - **user_id** (integer) - The ID of the user who sent the message. - **created_at** (string) - The timestamp when the message was created. - **url** (string) - A URL associated with the message, if any. - **files** (array) - An array of file objects associated with the message. - **buttons** (array) - An array of button objects associated with the message. - **thread** (object) - Information about the thread the message belongs to, if applicable. - **forwarding** (object) - Information about message forwarding, if applicable. - **parent_message_id** (integer) - The ID of the parent message, if this is a reply. - **display_avatar_url** (string) - The URL of the sender's avatar. - **display_name** (string) - The display name of the sender. #### Response Example ```json { "example": { "data": [ { "id": 194275, "entity_type": "discussion", "entity_id": 123, "chat_id": 456, "content": "Hello there!", "user_id": 789, "created_at": "2023-10-27T10:00:00Z", "url": null, "files": [], "buttons": [], "thread": null, "forwarding": null, "parent_message_id": null, "display_avatar_url": "http://example.com/avatar.jpg", "display_name": "John Doe" } ] } } ``` ``` -------------------------------- ### Configuring Incoming Webhook Source: https://www.pachca.com/articles/webhook This section explains how to configure the 'Incoming Webhook' settings to receive notifications from external services. It includes copying the Webhook URL and setting up message formats. ```APIDOC ## Configuring Incoming Webhook ### Description Details the steps for setting up the 'Incoming Webhook' section to receive notifications. This includes obtaining the Webhook URL and configuring message formats for bot responses. ### Method N/A (UI-driven setup) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```json { "message": "Текст сообщения" } ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### ViewBlockOption Schema Source: https://dev.pachca.com/guides/forms Defines the structure for an option within a view block, including its display text, value, description, and selection state. ```APIDOC ## ViewBlockOption Schema ### Description Defines the structure for an option within a view block. This includes the text to be displayed, a unique value, an optional description, and properties related to its selection state. ### Method N/A (Schema Definition) ### Endpoint N/A (Schema Definition) ### Parameters #### Request Body - **text** (string) - Optional - Отображаемый текст (Display text). - maxLength: 75 - **value** (string) - Optional - Уникальное строковое значение, которое будет передано в ваше приложение при выборе этого пункта (Unique string value that will be passed to your application when this item is selected). - maxLength: 150 - **description** (string) - Optional - Пояснение, которое будет указано серым цветом в этом пункте под отображаемым текстом (Explanation that will be displayed in gray under the displayed text). - maxLength: 75 - **checked** (boolean) - Optional - Выбрано. При значении true этот пункт будет выбран изначально. Только один пункт может быть выбран (Selected. If true, this item will be selected initially. Only one item can be selected). - **selected** (boolean) - Optional - Начальный выбор. При значении true этот пункт будет выбран изначально. Только один пункт может быть выбран (Initial selection. If true, this item will be selected initially. Only one item can be selected). - **required** (boolean) - Optional - Обязательность. При значении true поле будет обязательным для заполнения и отмечено символом * (Required. If true, the field will be mandatory and marked with *). - **hint** (string) - Optional - Подсказка, которая отображается под выпадающим списком серым цветом (Hint displayed below the dropdown in gray). ### Request Example ```json { "text": "Example Text", "value": "example_value", "description": "This is an example description.", "checked": false, "selected": true, "required": true, "hint": "Example hint text." } ``` ### Response #### Success Response (200) - **text** (string) - Отображаемый текст. - **value** (string) - Уникальное строковое значение. - **description** (string) - Пояснение под отображаемым текстом. - **checked** (boolean) - Флаг, указывающий, выбран ли пункт изначально. - **selected** (boolean) - Флаг, указывающий на начальный выбор пункта. - **required** (boolean) - Флаг, указывающий на обязательность поля. - **hint** (string) - Подсказка под выпадающим списком. #### Response Example ```json { "text": "Example Text", "value": "example_value", "description": "This is an example description.", "checked": false, "selected": true, "required": true, "hint": "Example hint text." } ``` ``` -------------------------------- ### Chatbot Buttons API Source: https://www.pachca.com/articles/knopki-v-chat-botah This section details the types of buttons available for chat messages, their structure, and usage examples. ```APIDOC ## Chatbot Buttons API ### Description This API enables the integration of interactive buttons within chat messages. Two primary types of buttons are supported: URL buttons for redirection and Data buttons for capturing user input. ### Button Types #### URL Buttons - Purpose: Redirect users to a specified URL. - Example Structure: ```json { "text": "All my projects", "url": "https://projects.com/list" } ``` #### Data Buttons - Purpose: Capture user input and trigger specific actions or responses. - Example Structure: ```json { "text": "👍 Agree", "data": "vote_yes" } ``` ### Limitations - Maximum buttons per row: 8 - Maximum buttons per message: 100 - Maximum length for button `text`: 255 characters - Maximum length for button `data`: 255 characters ### Request Example: Sending a Message with Buttons This example demonstrates how to send a message containing multiple buttons, including a row of two buttons, a single button, and a URL button. **Method:** POST **Endpoint:** `https://api.pachca.com/api/shared/v1/messages` **Request Body:** ```json { "message": { "entity_type": "discussion", "entity_id": 82753212, "content": "New order [Create one-page website](https://projects.com/inbox/534) for 8000 rub.", "buttons": [ /* Row of two buttons */ [ { "text": "👍 Agree", "data": "vote_yes" }, { "text": "❌ Disagree", "data": "vote_no" } ], /* Single button */ [ { "text": "🕒 Postpone for a week", "data": "pause_week" } ], /* Single URL button. */ [ { "text": "All my projects", "url": "https://projects.com/list" } ] ] } } ``` ### Response #### Success Response (200) - **message_id** (integer) - The unique identifier for the sent message. - **created_at** (string) - Timestamp of message creation. #### Response Example ```json { "message_id": 123456789, "created_at": "2023-10-27T10:00:00Z" } ``` ### Error Handling - **400 Bad Request**: Invalid request payload or parameters. - **401 Unauthorized**: Authentication failed. - **404 Not Found**: The specified entity or resource does not exist. - **500 Internal Server Error**: An unexpected error occurred on the server. ### Related Endpoints - **Edit Message**: Allows for modification of existing messages. Refer to the [Edit Message documentation](https://dev.pachca.com/messages/update/) for details. ``` -------------------------------- ### ViewBlockRadio Configuration Source: https://dev.pachca.com/guides/forms This section details the structure and properties for configuring a ViewBlockRadio component. It includes options for defining individual radio button choices, their values, descriptions, and selection states. ```APIDOC ## ViewBlockRadio Configuration ### Description Defines the schema for a radio button group component within a view block. Allows configuration of options, their display text, descriptions, and selection logic. ### Method N/A (Schema Definition) ### Endpoint N/A (Schema Definition) ### Parameters #### Request Body - **options** (array) - Required - An array of ViewBlockOption objects, each representing a selectable radio button. - **value** (string) - Required - The unique string value associated with this option. - **description** (string) - Optional - A descriptive text displayed below the option's main text. - **checked** (boolean) - Optional - If true, this option is initially selected. Only one option can be selected. - **selected** (boolean) - Optional - An alternative property for initial selection, similar to 'checked'. - **required** (boolean) - Optional - If true, this field is mandatory and marked with an asterisk. - **hint** (string) - Optional - A hint text displayed below the radio button group. - **title** (string) - Optional - The main title for the radio button group. - **hideHeader** (boolean) - Optional - If true, the header/title of the radio group is hidden. - **schemaName** (string) - Required - Must be "ViewBlockRadio". #### ViewBlockOption Schema - **value** (object) - Required - Defines the properties of the option's value. - **type** (string) - Required - The data type, expected to be "string". - **description** (string) - Optional - Description of the value. - **example** (string) - Optional - Example value. - **maxLength** (integer) - Optional - Maximum length for the string value. - **description** (object) - Optional - Defines the properties of the option's description. - **type** (string) - Required - The data type, expected to be "string". - **description** (string) - Optional - Description of the description field. - **example** (string) - Optional - Example description text. - **maxLength** (integer) - Optional - Maximum length for the description string. - **checked** (object) - Optional - Defines the properties of the checked state. - **type** (string) - Required - The data type, expected to be "boolean". - **example** (boolean) - Optional - Example boolean value. - **selected** (object) - Optional - Defines the properties of the selected state. - **type** (string) - Required - The data type, expected to be "boolean". - **example** (boolean) - Optional - Example boolean value. ### Request Example ```json { "options": [ { "value": { "type": "string", "description": "Unique string value for this option.", "example": "option1", "maxLength": 75 }, "description": { "type": "string", "description": "Additional explanation for the option.", "example": "This is the first option.", "maxLength": 75 }, "checked": { "type": "boolean", "example": false }, "selected": { "type": "boolean", "example": false } }, { "value": { "type": "string", "description": "Unique string value for this option.", "example": "option2", "maxLength": 75 }, "description": { "type": "string", "description": "Additional explanation for the option.", "example": "This is the second option.", "maxLength": 75 }, "checked": { "type": "boolean", "example": true }, "selected": { "type": "boolean", "example": true } } ], "required": true, "hint": "Select one of the options above.", "title": "Choose an Option", "hideHeader": false, "schemaName": "ViewBlockRadio" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. - **message** (string) - A confirmation message. #### Response Example ```json { "status": "success", "message": "ViewBlockRadio configuration updated successfully." } ``` ```