# Bot functions: teach it to create deals, send reports and requests

Functions are actions the bot performs during a conversation: create a deal in the CRM, send a Telegram report, call your address by API, send a file or hand over the chat.

Updated: November 14, 2026 · https://onswer.ai/docs/en/bot/functions · Onswer

A function is a rule of the form "if X happens, do Y". For example: "If the customer is ready to order, collect the name and phone and pass them to the manager." Functions are in the bot's dashboard under "Functions".

## How to create a function

1. Press "Add function" and give it a name.
2. In the **description** explain to the bot when to call it.
3. Add **parameters**: what the bot must find out from the customer before the call (name, phone, date). For each give a name, a type (text or number), a hint for the AI and whether it is required.
4. Choose **what happens** on the call (the "Sending results" block).
5. Choose the **reaction**: send nothing, send a set message, give the bot an instruction, or let the AI decide.
6. Turn the function on. The bot does not use a disabled one.

## What a function can do

| Action | What it does |
|---|---|
| CRM, amoCRM, Bitrix24 | Creates a deal in the connected CRM. A repeat request from the same chat becomes a note on the same deal |
| Telegram report | Sends a message to your Telegram |
| Custom API | Sends data to your address, for example to your system. Headers (including keys) are stored encrypted |
| Google Calendar | Works with the calendar |
| Send a file | Sends the customer an attached file |

For a CRM you can say which deal field each parameter goes to. Parameters with no chosen field are matched by name, and the rest go into the deal's note.

## What to do after the call

In the "Post-scenario" block choose: continue the conversation, pause the bot, add to the instructions, or switch the agent (hand the chat to another bot).

## Example: a delivery request to your system

The goal: a customer writes "I want to order a delivery", the bot collects the details and sends the request to your server. The customer gets an order number.

**1. Name and description.** Name: "Delivery request". Description (the bot decides when to call the function by it): "Call when the customer wants a delivery and has given the address and a convenient date".

**2. Parameters:**

| Name | Type | Hint for the AI | Required |
|---|---|---|---|
| name | text | The customer's name | yes |
| phone | text | Phone for the courier, as +7… | yes |
| address | text | Delivery address with street and building | yes |
| date | text | Delivery date, e.g. 20 November | yes |
| comment | text | Wishes for the order, if the customer named any | no |

While a required parameter is unknown, the bot does not call the function: it asks the customer first.

**3. Sending results → "Custom API".** Address: `https://shop.example.kz/api/orders`, method POST. Add your system's key as a header, for example `Authorization: Bearer …`. The key is stored encrypted and is not shown in the dashboard after saving.

The bot sends JSON to this address, with the parameter names as keys:

```json
{
  "name": "Dinara",
  "phone": "+77011234567",
  "address": "Almaty, 10 Abay St, apt 5",
  "date": "20 November",
  "comment": "call an hour before"
}
```

With GET the same data goes in the address (`?name=Dinara&phone=…`). The server must answer within 10 seconds. Internal network addresses and localhost are not accepted.

**4. Reaction to function execution → "AI agent decides itself".** The bot sees your server's answer. If the server returns `{"order_id": 1042}`, the bot writes something like "Order #1042 is placed, the courier will call on 20 November". To always send the same reply, choose "Message" and write the text yourself.

**5. Post-scenario → "Continue dialogue".** If a manager should take over after the request, choose "Pause dialogue".

**6. Testing.** Enter sample data and press "Show what will be sent": you see the address, method and JSON, nothing is sent. Then "Run for real" (press it twice): the request goes to your server and you see its answer.

If your server answers with an error or does not answer, the bot does not promise the customer the order is placed: it says the request went to a person and hands the chat to a manager. The same request with the same data is not sent twice within a day.

## Testing

A function card has a "Test" block: enter sample data and press "Show what will be sent" (nothing is sent) or "Run for real". A test deal in the CRM is named "Test: ...", and a file is not sent to anyone during the test.

> **Tip:** If you just need a lead in the CRM, the [amoCRM](/docs/en/integrations/amocrm) or [Bitrix24](/docs/en/integrations/bitrix24) integration is usually enough: the contact and the deal are created on their own. Functions are for non-standard scenarios.
