# Chatbot for online booking

## General Information

A chatbot for online booking is a set of funnel builder functions that allow you to automate the process of scheduling services for your company.

The bot’s workflow is based on the sequential execution of functions: receiving data to display to the client, then passing this data on to trigger new functions and obtain new results.

As the client moves through the funnel, you should pass into each subsequent block only the data that corresponds to the client’s choice—use this data to configure the next function calls.

Thanks to the ability to retrieve intermediate data (for example, employee positions and service categories) and pass it along for filtering employees and services, you can flexibly configure your funnel and give the client control over the steps of its progression.

{% hint style="info" %}
All the methods described in this article return an array of dictionaries.

For convenient work with them, we recommend reviewing the sections [Arrays](broken://pages/GdKjdvJlDbSW4kLQZgSU) and [Dictionaries](broken://pages/WAoFJJjcR8vja9QnBHGj).&#x20;

Also, to use the function for generating user actions (service selection, date, booking), we suggest considering the [tools\_make\_button\_str\_checker method](/chatbot/functions/calculator/arrays.md).&#x20;
{% endhint %}

Below is a diagram of the bot’s workflow, where each block of the diagram represents a specific function call, and the arrows indicate the flow of data passed from block to block. The information passed in these flows allows you to filter requested data, as well as create, cancel, or modify a booking time.

<figure><img src="/files/vXQd0VdQq4NIVuFx2j4u" alt="" width="563"><figcaption><p>chatbot diagram</p></figcaption></figure>

{% hint style="info" %}
To see a detailed configuration diagram of the online booking chatbot with the functions in use, refer to the [Bot Implementation Example](#example-of-bot-implementation) section of this article.&#x20;
{% endhint %}

## Retrieving Branch Information

To create an online booking funnel and retrieve information about project branches, use the get\_companies\_for\_booking function.

The function returns a list containing data for each branch (funnel) that has “Online Booking” enabled in its settings.

The data is provided as key-value pairs and includes the branch identifier (id), name (name), and address (address).

The function does not take any parameters.

### Example of usage:

Function call within a block:

<figure><img src="/files/Lz0UJpIU0QIHkE0Nmevj" alt="" width="375"><figcaption></figcaption></figure>

Example of returned data:

<figure><img src="/files/wBx9555aQUqlyCh53xTJ" alt="" width="375"><figcaption></figcaption></figure>

## Retrieving information about positions or service categories

The function get\_categories\_for\_booking(company\_id) allows you to retrieve a list of all types of specialists or service categories for a branch.

Each item in the returned list contains an identifier (id), a name (name), and a description (description) of the position or service category. Data is represented as "key-value" pairs:

#### Parameters:

<table><thead><tr><th width="310">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>company_id (required) </td><td>Branch identifier, expected format — integer.</td></tr></tbody></table>

### Example of usage:

Function call example in code block:

<figure><img src="/files/EsOABxODX6E9kiRdEQYw" alt="" width="375"><figcaption></figcaption></figure>

## Retrieving information about employees

If you need to provide information about branch employees, use the function  get\_employees\_for\_booking.

The call will return a list of data containing the employee identifier (id), name (name), information (information), and job title (job\_title).

You can also filter employees by service list, job title, or service category. To do this, pass an additional parameter in the function call: service\_ids, job\_title\_id, or service\_category\_id.

#### Parameter order:

company\_id -> service\_ids ->  job\_title\_id -> service\_category\_id

#### **Parameters:**

<table><thead><tr><th width="287"></th><th></th></tr></thead><tbody><tr><td>company_id (required)</td><td>Branch identifier, expected format — integer;</td></tr><tr><td>service_ids (optional)</td><td>Service ID or a list of service IDs, expected format — an integer or a list of integers in square brackets separated by commas, e.g., [844, 845]</td></tr><tr><td>job_title_id (optional)</td><td>Job title ID, expected format — integer;</td></tr><tr><td>service_category_id (optional) </td><td>Service category identifier, expected format — integer;</td></tr></tbody></table>

**Note:**

If you want to retrieve all employees of a branch, leave the values for service\_ids, job\_title\_id, and service\_category\_id empty.

* Call example: get\_employees\_for\_booking(14275391)

To filter employees by a list of service IDs, pass the list as the second parameter and leave job\_title\_id and service\_category\_id empty.

* Call example: get\_employees\_for\_booking(14275391, \[844, 845])

To filter employees by job title, pass the ID to the job\_title\_id parameter and leave service\_ids and service\_category\_id empty.

* Call example: get\_employees\_for\_booking(14275391, “”, 1021)

To get employees providing services of a specific category, leave service\_ids and job\_title\_id as empty strings, and pass the selected category ID to service\_category\_id.

* Call example: get\_employees\_for\_booking(14275391, “”, “”, 1019)

### Example of usage:

Function call in a code block:

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

Example of returned data:

<figure><img src="/files/VHDeDNwzLHtuKsMEQife" alt="" width="375"><figcaption></figcaption></figure>

## Getting information about services

To get information about the services provided by the branch, use the **get\_services\_for\_booking** function.

As a result of the call, the bot will return a list containing service data. Each service entry includes an identifier (**id**), a name (**title**), a description (**description**), a price (**price**), and the service duration in minutes (**duration**).

You can filter the resulting list by service category, by employee, or by both service category and employee simultaneously. To do this, pass the additional parameters **service\_category\_id** and/or **employee\_id** when calling the function.

#### Parameter order:

company\_id -> service\_category\_id -> employee\_id

**Parameters:**

<table><thead><tr><th width="310"></th><th></th></tr></thead><tbody><tr><td>company_id (required) </td><td>Branch identifier, expected format – integer;</td></tr><tr><td>service_category_id (optional) </td><td>Service category identifier, expected format – integer;</td></tr><tr><td>employee_id (optional) </td><td>Employee identifier, expected format – integer;</td></tr></tbody></table>

#### Note to the “Parameters” section:

If you want to retrieve all services of a branch, leave the **service\_category\_id** and **employee\_id** values empty.

* Call example: get\_services\_for\_booking(14275391)

If you want to filter services by category and/or employee, pass the corresponding identifiers into the **service\_category\_id** and **employee\_id** parameters. To filter by only one parameter, provide an empty string for the other one.

Calls examples:

* get\_services\_for\_booking(14275391, 1018) - service category filter;
* get\_services\_for\_booking(14275391, “”, 512978) - employee filter;
* get\_services\_for\_booking(14275391, 1018, 463665) - filtering by both parameters;

### &#x20;Example of usage:

Calling the function inside a block:

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

Example of returned data:

<figure><img src="/files/nFumcBxN3UYydSrTi1Eq" alt="" width="375"><figcaption></figcaption></figure>

## Getting available booking dates

After the client has selected the services for booking, they need to retrieve a list of available booking dates.

To generate this list, use the **get\_dates\_for\_booking** function.

The function will check for available time slots and return a list of suitable dates in the format “day.month.year”.

#### The order of parameters is as follows:

company\_id -> service\_ids -> employee\_id -> days\_limit

#### Parameters:

<table><thead><tr><th width="309.33941650390625"></th><th></th></tr></thead><tbody><tr><td>company_id (required) </td><td>branch identifier, expected format – integer;</td></tr><tr><td>service_ids (optional)</td><td>list of service identifiers for booking, expected format – integer or a list of integers in square brackets separated by commas (e.g. 842 or [842, 843]);</td></tr><tr><td>employee_id (optional)</td><td>employee identifier, expected format – integer. If the parameter value is left empty or passed as an empty string “” – the function will search for available dates among all employees who provide the full set of services from the service_ids list;</td></tr><tr><td>days_limit (optional)</td><td>number of days from the current date within which the search for available dates is performed, expected format – integer, default value – 14 (days);</td></tr></tbody></table>

### Example of usage:

Calling the function inside a block:

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

Example of returned data:

<figure><img src="/files/1us5G6dtpDzvSq950HBg" alt="" width="375"><figcaption></figcaption></figure>

## Getting available booking slots

To get a list of available booking slots, use the **get\_slots\_for\_booking** function.

The function will check for available time on the selected date and return a list of free slots in the format “hours:minutes”, for example \[“09:00”, “11:00”, “14:30”, “16:00”].

#### The order of parameters is as follows:

company\_id -> service\_ids -> employee\_id -> slot\_interval

#### Parameters:

<table><thead><tr><th width="284"></th><th></th></tr></thead><tbody><tr><td>company_id (required)</td><td>branch identifier, expected format – integer;</td></tr><tr><td>service_ids (optional) - </td><td>list of service identifiers for booking, expected format – integer or a list of integers (e.g. 842 or [842, 843]);</td></tr><tr><td>date (optional) - </td><td>date for slot checking, expected format – string in the form “day.month.year”, for example “01.01.2024”;</td></tr><tr><td>employee_id (optional)</td><td>employee identifier, expected format – integer. If the parameter value is left empty or passed as an empty string, the function will search for free slots in the schedules of all employees working on the selected date and providing the full set of services from the service_ids list;</td></tr><tr><td>slot_interval (optional) </td><td>interval in minutes between available slots, expected format – integer, default value – 30 (minutes);</td></tr></tbody></table>

### Example of usage:

Function call in the block:

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXc7GJ9EjdCro_idrF14dVYscslN653oUESQaAFjHBWZrSO8q4joGD95kXjFfaX-E2oRT_nLCdKNrGdN9j5wBVJFKOgiyG2ZGDJNjR-l3OAhvP2E0pPTA0dOiYD3WxGdxdD57bRO-UC3CoGVVO4XV3Cq5BNpc8cZ1S6S0lsnlw?key=KyjJFgzVYb53MOCGur8CUg" alt=""><figcaption></figcaption></figure>

Example of returned data:

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXe6V_i1iPe4C6A6CDJPu6GNK4fFLzUzq4ktYRRf01jRRgvRl87Ir3hWs2GbWRsYatbz0o8srDyE6pHklrvZ129tilNr5fuR9C_lhQP75MO-_Mfi9JVgcTvHoldK6Y8dcZ_cQamJp2JDxBfA8OU3a9cDgPavncaz-9aU_p31qg?key=KyjJFgzVYb53MOCGur8CUg" alt=""><figcaption></figcaption></figure>

## Creating a booking

To create an online booking, use the **create\_booking** function.

If the booking is successful, the function will return information about the operation status (status) with the value True and the booking details (booking) in a “key: value” format.

The new booking data includes:

* identifier (id),&#x20;
* date (booking\_date),&#x20;
* time (booking\_time),&#x20;
* service names (services),&#x20;
* booking duration(service\_duration),&#x20;
* total cost (total\_cost),&#x20;
* assigned employee’s name (employee\_name), and his job title (job\_title),&#x20;
* branch name (company\_name) and branch address (company\_address)&#x20;

in a “key: value” format.

#### Parameter order:&#x20;

company\_id -> service\_ids -> booking\_date -> booking\_time -> employee\_id

Parameters:

<table><thead><tr><th width="288"></th><th></th></tr></thead><tbody><tr><td>company_id (required)</td><td>branch identifier, expected format – integer;</td></tr><tr><td>service_ids (required)</td><td>list of service identifiers for booking, expected format – integer or a list of integers (e.g. 5 or [5, 10, 15]);</td></tr><tr><td>booking_date (required)</td><td>booking date, expected format – string in the form “day.month.year”, for example “15.01.2024”;</td></tr><tr><td>booking_time (required) </td><td>booking time, expected format – string in the form “hours:minutes”, for example “12:30”;</td></tr><tr><td>employee_id (optional)</td><td>employee identifier, expected format – integer. If the parameter value is left empty or passed as an empty string “”, the function will book with a random employee who provides the full set of services from the service_ids list, if they are available at the specified date and time;</td></tr></tbody></table>

### &#x20;Example of usage:

Function call in the block:

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXdb3Fq2gqGtJ-QK342Hr12Ckv-krW_04_uAeJsCcnKpCq_iTC8mAxXjXvc_UqOVAOfm7WGcHYlfcvZjImoZXoNuPYCctsZOPB35toHI4zWMmK-sr3GoEdujlh8YQRxXsF_qN-I836wsU3AKhMvP8t0KiF0h6syWhECIxsynkQ?key=KyjJFgzVYb53MOCGur8CUg" alt=""><figcaption></figcaption></figure>

Example of a successful booking response:

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXfsZPfW9v1VoJqC3nNqtnlLQJS-KhAaEi3uUzhz26vYmcxajMRMwd7NnZVZB2LpmavglbNibSpAAJIlo0mbge1_K6rguZTf1tE4NxkBPmKQ1GCy0x47vzfkIV5DTN-R-RlYpMZ-bfAQ-vrZ_tEM6mugSbn0E5BAjHCVN2Gdmw?key=KyjJFgzVYb53MOCGur8CUg" alt=""><figcaption></figcaption></figure>

When creating bookings and subsequently requesting available slots again, you’ll notice that the lists have shortened. For example, on 05.02.2024, the 18:00 slot is no longer available (it was only free in Victoria’s schedule), and for Paul Thompson, bookings for a men’s haircut and beard styling can now be made from 9:00 to 14:00, since the total duration of the services is 1 hour and 45 minutes, and Pavel already has another booking at 16:00.

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXfglzV1DHx8clVfshVMInDi9MOS6sAlPGG8Axr6FYKBAeINwRaj2gvJMRYNcec7ZmDCnFKYCkU64AQqz2mgMWxCnp4G4YPRPb6C9D9g9KLKFM2e2bCVpBA2refY_fChq-W1uNy196r5d8dNZUudGRg-2qgN9NX20lCteL8AZw?key=KyjJFgzVYb53MOCGur8CUg" alt=""><figcaption></figcaption></figure>

## Getting information about a client’s upcoming bookings

You can view a client’s current bookings by calling the **get\_bookings\_info** function.

The response will return a list of active bookings, along with detailed information for each booking.

Booking information is provided in a “key: value” format and includes:

* booking identifier (booking\_id),&#x20;
* date (booking\_date),&#x20;
* time (booking\_time),&#x20;
* identifiers (service\_ids) and names (service\_names) of selected services,&#x20;
* booking duration (booking\_duration),&#x20;
* total cost of services (total\_cost),&#x20;
* identifier (employee\_id) and name (employee\_name) of assigned employee's, and his title (job\_title),&#x20;
* branch identifier (company\_id)&#x20;
* branch name (company\_name) and address (company\_address).

#### Parameters:

<table><thead><tr><th width="253"></th><th></th></tr></thead><tbody><tr><td>client_id (optional)</td><td>client ID, req – This parameter is required if you want to retrieve bookings for a specific client; by default, it uses the client ID from the chat with the bot.</td></tr></tbody></table>

### Example of usage:

Function call in the block:

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXeKlJcFxIx3cc_3vb8g0MARiqu6iNE4eW8BEmVY21MjT74GxS2U7JKFaAn6Sia99v4kQ4O8HuHFYkQJs8jCNmtpZHIkKq1SZ3_3BCBSA7mCs_iXVk6Ucu8hWTOHN7mPa0J5LGG5QSRK8TSP9BEZracVVNQBZKuZkLJx36r_TA?key=KyjJFgzVYb53MOCGur8CUg" alt=""><figcaption></figcaption></figure>

Example of returned data:

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXcHzfzRWdUXAmr-iwrHhcdpHYraOD--i4jjI5ftsc-KRzzEOOFArT3hKZE--WucI4m3_b2v0DK99dV4EL2BQ9d0U2q-2fGHM6RiCHX_YUl7kgI-SA4zJIHs4zFte6GhgQAMfUY9Qim4THusxMhKielEnXQuHzapLqmh_oZm?key=KyjJFgzVYb53MOCGur8CUg" alt=""><figcaption></figcaption></figure>

## Changing booking date and time

A client can independently change the booking date and time. To do this, they need to access the funnel block where the **modify\_booking\_time** function is called.

If the operation is successful, the function will return the operation status (status) with the value True and a message (message) “Booking time modified” in a “key: value” format.

#### Parameter order:&#x20;

order\_id -> new\_date -> new\_time

#### Parameters:

<table><thead><tr><th width="300"></th><th></th></tr></thead><tbody><tr><td>order_id (required) </td><td>booking identifier, expected value – integer;</td></tr><tr><td>new_date (required)</td><td>new booking date, expected format – string in the form “day.month.year”, for example “16.01.2024”;</td></tr><tr><td>new_time (required)</td><td>new booking time, expected format – string in the form “hours:minutes”, for example “14:30”;</td></tr></tbody></table>

### Example of usage:

Function call in the block:

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXcDyllYwQDcuLOWIAFTCHb4A765baTgyFrir86V0h3ja3OQpECP2D5TszmK-M_PbKmQRVbp1LFLUMc_JIU4m9562kGnWz9WILVhjpMhf1jZw5bOUXCuBbUasMKWeaTo0pATOPujX4QK6laEk2TlXPU6Qycc7xlih1KbEBxK?key=KyjJFgzVYb53MOCGur8CUg" alt=""><figcaption></figcaption></figure>

Bot response for a successful operation:

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXdKqYrp28WS18aq3-_0I_3iDJUc2FmzwsilP1-5do9jmVjjVJ3Igfflo9rMnU_KEWWdAUYSZtjp6B0bVxwBcc7P21RvWVIeCOEAq0pNEh1KYDxJATu71S1Fiil4gicJeFuq5MAcp7bnQdUqRf8kjrWMXuA2_Fl09tjKwEPI?key=KyjJFgzVYb53MOCGur8CUg" alt=""><figcaption></figcaption></figure>

The previously occupied 16:00 slot is now available for booking, and creating a new booking for the same services can now only be done from 11:00

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXeM-8-vu5dfYf4DlMnzlWTk08tQm80ne-qTBJleANK0Mjn-TuZWyMbO13Hex4FzdwvCgQspNeErgWwQkTZIejzDWK1BItCGxrLpAi9D0XFx75rqFvUF9UChQ_LoZqUNozZzKwubmGkx7XSgsTm-_1CBORCt5Nidh5X4ohbx?key=KyjJFgzVYb53MOCGur8CUg" alt=""><figcaption></figcaption></figure>

In the client’s booking information, you will also see the updated booking time:

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXeCyMMrRSlqAdCpmu0-HWsS6iKxW6xHjdtcnZ2NjxLTaRy7W_w3mhyLZQ2PjZgpvbmHRnRML-5A6hTwHpgpLaTerklX-opM8_UTQAeuT-ev2bd7AvC6N1ynPf50EUVRs6m4hZU4YIKnWQRamRcGbror5uJ7ElZ2v2KPtX1NxQ?key=KyjJFgzVYb53MOCGur8CUg" alt=""><figcaption></figcaption></figure>

## Cancelling a booking

A client can independently cancel an existing booking. To do this, they need to access the block where the **cancel\_booking** function is called.

A successful cancellation will return the operation status (status) with the value True and a message (message) “Booking deleted” in a “key: value” format.

Parameter order:

pipeline\_id -> order\_id

Parameters:

<table><thead><tr><th width="321"></th><th></th></tr></thead><tbody><tr><td>pipeline_id (required)</td><td>branch identifier, expected value – integer;</td></tr><tr><td>order_id (required)</td><td>booking identifier, expected value – integer;</td></tr></tbody></table>

### Example of usage:

Function call in the block:

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXdWFqf619l5j1eQoe4p6QCPqGGsqcyEefKLs5PJxPwecillJaxUnQSC5eHFcT2olsrM62PHJDVGyxeD6Tl2xg3id27f-p51spmVZFjlDhSwzw3TwMx-CbQT9n3fnjYLPCO4wlqtKdB0cd1W36dp9wXYg4gEVJh6eketyDUQ?key=KyjJFgzVYb53MOCGur8CUg" alt=""><figcaption></figcaption></figure>

Bot response for a successful cancellation:

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXe7FcrjKQxzoEgo3wfMuUt0a9zkPVkb02ojx5pZ3KYWU5NfLazmLhgCaNxvigreYXXfzYFEhd5KyF7D3808VLBGl5Cte7YRXI0cWQK3J9ZV05G5y5XUIXGq1Arcac2KrPmHnCCakarcTFXd_9X5_4yYsI6j4rpMySaZr3lA?key=KyjJFgzVYb53MOCGur8CUg" alt=""><figcaption></figcaption></figure>

After the cancellation, the “09:00” and “10:00” slots are available for booking again:

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXcRLLDJ0un8QPUj11yC8VDy2TlbbgUHuDd13YSQ3AZU3ey4Cg00SMEke5LFPKWGHR8em7BWHiH8l-bSqGICNAU5CP9ORBGI9CFMKziB0JQLZA0QUvYJ8q-SXXQGQsPCnEWdNrDZ1G7bZupR4zOLgGpJt9TgZBxG_R1MPf9f?key=KyjJFgzVYb53MOCGur8CUg" alt=""><figcaption></figcaption></figure>

## Example of bot implementation

### Chatbot settings

**Block №1.** Start. No special actions required

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXcXoXRmydVuSiBv9lAWBG-5rDy8cIcNbk2zjsJ7o5kxShJEExU13A9O2v9pFuqG6oTndOvrnRft3jHQaZFf-7RGYiFM09FPzpQdrdS47_ttQcgLvbDExj9xIBEjJ80qVPHSAFzfth5zcO_rCvqk66FaK-Nx?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption><p>Блок 1.</p></figcaption></figure>

**Block №2**. In this block, we retrieve the data that will be provided to the client.

Calculator content description:

* comp\_id - service block identifier, which can be found in the “Services” section;
* data - information about the provided services
* res - dictionary with data needed for generating buttons and setting conditions
* numbered\_list - may be useful if the list of services needs to be duplicated in text form
* buttons - array of buttons generated from the service data
* checker - array of service names, used to set conditions for moving to the next block

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXdLGPcvhDRumGklk525zCB4VEqziavYPoNoqJiC3XD036d1R_jcSF2yeDhFZvrTOTxFrALYNF9_ezfdbKxgn6fSuIkTyCzHb9Cxaw3cW9ywtyUbvf3Bezb3ukuZC3fFuM5e0Jb8tNCyWRqUv-8aev2MHeo?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption><p>Блок № 2</p></figcaption></figure>

**Block №3**. Retrieve and display data about the selected service.

title -in the array of dictionaries **data**, find the dictionary where the key **title** equals **question**. From that dictionary, get the value for the same key **title**

description - similarly, get the value for the key **description**

price - similarly, get the value for the key **price**

serv\_id - similarly, get the value for the key **id**

b - create an array of strings that will be displayed as buttons under the message

res - from the array **b**, create an array of dictionaries as in the previous block

buttons - obtain the array for displaying the buttons

Now we have variables containing the name, description, and price of the service selected by the client

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXfoMVt3v-buSCBlpe9hKGoFoemSKQW0oeLLZ7LZwZ24vR507mCOTzuewDhUsfCangNsex0sKbdc9k-HeJXQ-ermTNsf_p3O4xtlpygOhFmzyWZ2cjCDxHUUdZq0gCsiSGJmSWIkN04n4XOkpX2t6nHVORhb?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption><p>Блок № 3</p></figcaption></figure>

**Block №4.** Display available booking dates

print\_dates - use the function to get available booking dates for the selected service

print\_dates - add the string “Return to service list” to the array of dates if you want this button to appear along with the dates.

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXeNbqnf6RHcvKlt8ECsxm7uUQpLClSJ2kVgW9HPi35Pmq5XtsAR_yXWCxHr_0CYwJ4whUQfdof71uxnPt8BHxobfYJdxGeDhmf3BXd5NHAPyC12RT6cRIzn8g_Kda70WRAhjYhJ85Vfhi9i40aqUu-Kvg8E?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption></figcaption></figure>

For the arrow returning to the previous step, set a higher priority than the arrow with #{checker}, because #{checker} also contains the condition “Return to service list”.

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXcuUIlqDrtiEGIX7Dk8d1YILa_s9F2bRzrgcgQ_eytukzhEe2IDatqW7VPPgyQeLfzOYqtY-vL2rdCaGYSf3PSRpe4JSXlHD68TJHrOHec6tBRvMOp_sIMs3bqWAQKX9jWPDsWjY-CGQnZEc8QPr2ZGikXQ?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption></figcaption></figure>

**Block №5.**\
В блоке №5 мы сохраняем выбранную клиентом дату. Это нужно сделать в отдельном блоке потому, что на следующих этапах при возврате в Блок 6, переменная question уже не будет содержать в себе выбранную клиентом дату.

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXfBnoXAoC-hwhm7MJk242wb1qbGz4qwZr-L180d271_eNanul0suKBZUdiYAy95nTZD7rVZv5bYgnB8dZ3u0pW75yMtdz2mQ6bzqTTAxEhVZAihD-VCj-45M9jldb6Ic_JuyDEWsvlodPlxY-2150k62HuW?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption></figcaption></figure>

**Блок №6.** Выбор и отображение доступных ячеек для записи.

data - получаем доступные ячейки.

Логика такая же, как в Блоке №4 с выводом доступных дат. Также важно не забыть настроить повышенный приоритет у стрелки “Вернуться к выбору даты”

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXdO4UUM3CyFvJN5lNulwUwHbEWQhng6kaW_YVmOrbkP-2VoQHB3Sg09TkpPv5joYo3EV_9iaFI68B4dfgzL49RveaMzZHQIOs7mKyzFgsA6PKrwrKM0oMKZVGMZjbyz2rxIi0kpaOZFZIStEzUvASiyunli?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption></figcaption></figure>

**Блок №7.** Сохранение выбранного времени в переменную и попытка записать клиента.&#x20;

choosed\_time - сохраняем время

a - попытка записать клиента

booking\_result - получаем результат выполнения функции.&#x20;

Получить результат необходимо, так как несколько человек могут попытаться записаться на одно время в один момент.&#x20;

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXczzYBOEvinNi3ixDewD_V6XrrfAwjChrujdPmo7MK1m1qV-8depW4IV8_-VxA6_u2RKwTBYifAi4q5kxN1OEG_6m9exNS-hAvtB2VH49kP-X5uuAboxpgb--ugGdit-JI6inwRHXMQtbPbqSy-oe3ZvLi_?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption></figcaption></figure>

**Блок №7.1.** Записать клиента не удалось.

Этот блок нужен только для сообщения об ошибке. После отправки сообщения возвращаем клиента на выбор времени для записи

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXflFxwu5IdfEsIzK1dpt4STbIc6GY2HDz-NvpW6vmG12aBRj5TWgaN2O_YWlLaCSN3B52bMDf8EIMo2kKofNkTzD_TqRWu7F5rEL1NiFrlPiJwLntEG9DgdSKYocFtNQMADKTMJFHADE4fPUgeFJJ5crM3y?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption></figcaption></figure>

**Блок №8.** Запись прошла успешно.

Сообщаем клиенту, что он записан на услугу и отображаем кнопку для оплаты.

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXebWZ4RSKanJHHLwJmqRzx_sQAwEqpnz7hMmMOqJziY9J4IpSAPevmApHRz_oR3GEIuceV_IOAi1XdpUMqNtgC5nI-vB75hIq_9NDudNSGzYESotA-rl-WCFjLtcVQA6kiFvcDvij0koA2ttg4NVvwwiQI?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption></figcaption></figure>

Пример настройки кнопок.&#x20;

Для настройки используем переменные, которые мы получили в блоке №3:

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXcuWNRouJXZN4GcbOP_g5b2cBGtzMjW3t20fJDYvPqy02QHr_Mx7seJfSJSjnieOxRiuZ2eQ8F8iJEcBkllOYNYR4cXYGFfuK69jsVhnLUuq-3a2a5Lts8UXEJyP1m0DvNoEmyDiMcXXpLQX8srFEgvnSo?key=Gdkru5ZyRiCm0ujtl74quw" alt="" width="375"><figcaption></figcaption></figure>

**Блок №8.1.**

В этом блоке подтверждаем успешную оплату. Переход в блок настраиваем в соответствии с используемой платежной системой

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXcKwiimzQWaWQdY87DhVF0EHgXGIN1am1ybhpQIN2ZjubanvoORX4nF86oxQfeDUH0rSfPPLQp4BVRDYJh0wMWQRp-ko-Dm8PmWeBPyA9KvPiSwDt6GkzUrsFw9ITDDjH7-JsG97mxgwZ_8OtCMFVVkhPza?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption></figcaption></figure>

**Блок №8.2.** Клиент не оплатил услугу. Отмена записи

Если клиент не оплатил вовремя услугу, мы можем отменить запись, если это необходимо.

or\_id - получаем id заказа

cancel\_status - после выполнения функции получаем ответ, успешно ли выполнена отмена.&#x20;

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXe0S7A8roVZ-cqy20A7SABHlZEH561HeUudCIFcTEmV19DibNgEWLoEqZ45pWtukMuEdaxuJ1KjsvAiR7hFeGCrNLIMBghZIglifArlGWnBA1O6uKfGoeHRyfYihmIH1EalHVrqOKJKW6AsvOraqTIM2k6j?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption></figcaption></figure>

В этом примере клиент попадет в блок отмены через 5 секунд после получения ссылки на оплату, в реальной же ситуации вы можете установить необходимое количество времени, главное не забудьте включить переключатель “Отменить, если покинул блок”.

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXf4JnYF9gJdYh1IeHnh0KIP8TBthzNABp_TjejLyQXugQBBb_Xvz4yfoedExR9VJy6koxfpNqGkYe38fioTFrzuuioJjVVVp2HLB9w8gRt5LqMcFX5samcaj30aBLV69MVTCNrg2bEbnVaoxv5IuUidtB3Y?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption></figcaption></figure>

Полная схема:<br>

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXelLMX7_UQ0Op_QDn8S-GKMp68O-cJDYMFviZLju8TUjMMYKIMwyv9AePru93ccedeKajHSx4kP5e4t1XFfAtabSJBfluvE7q-VsZkx1rO3ICGBm0dvVUtEriaro8UXixY6XratDgILrSOMHfXIpfaHb8Y?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption></figcaption></figure>

### Демонстрация<br>

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXcgQC7kI1xOkzZOYyijAdDELqmlgit1O615fU0RQjYF-g-ztgkNayFf2gaPupplvgiAoE1T_bOdSh-dLO4Oaqu2AVnmh-5uooWhCc3BOqqdIzgQh6gV4r3l86VJHRgXEOZTmKD3HqbXoTuRrpZ8qYJOj4Ol?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption></figcaption></figure>

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXcMs9Sg7IOqKfcvVdL5ud1odnPrlHg0Acfa71bnpFAfmQ_7GP4AsKI7JI2GVzAQZV9a2d0jMGmFamGiuD_mMG00SsfAQZvje_aPGybcmsKBU0F2VpTbv5H9qPPA5gszFwQyZaaG3TH9HDutSZE19JzNo5nV?key=Gdkru5ZyRiCm0ujtl74quw" alt=""><figcaption></figcaption></figure>

## Callback о записи

В диалог с клиентом после записи будет приходить колбек — уведомление о записи — следующего вида:

<figure><img src="/files/EfFIWPTptrKrVBha0hMM" alt="" width="464"><figcaption></figcaption></figure>

<mark style="color:orange;">**new\_order\_in\_calendar**</mark> - не изменяемая часть колбека&#x20;

&#x20;<mark style="color:yellow;">**\[489046159]**</mark> - order\_id  идентификатор заявки&#x20;

<mark style="color:red;">**Добавлена запись даты\_и\_время\_записи**</mark>

<mark style="color:purple;">**на 30 минут**</mark> - длительность услуги&#x20;

<mark style="color:red;">**Объекту: Тест 30**</mark> - какому именно объекту добавлена запись

Вид самого колбека:

***`new_order_in_calendar: [489046159] Добавлена запись с 2025-06-01 14:00 до 2025-06-01 14:30 на 30 минут. Объекту: Тест 30`***

Настроить реакцию на колбек можно прописав значение в условии блока:

<figure><img src="/files/nHFNa6gsIOqAbiDOV4E9" 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://docs.mavibot.ai/booking/chatbot.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.
