Sends a text message to a user, group, or channel.
π‘ Messages longer than 1800 characters are delivered as a text file instead. The first 1800 characters stay intext, and the full message arrives as atext_fileyou can download. Give users a Read more action that opens it.
Request
method is "sendMessage".Field | Type | Required | Description |
chat_id | String | Yes | The target chat or user. |
text | String | Yes | The message body. |
app_id | String | Yes | The app the message belongs to. |
reference | Long | Yes | Your local id for the message. Echoed back in messageAck so you can match them up. |
to_user_id | String | Optional | Target a single user inside a group or channel. |
reply_to_message_id | String | Optional | Set this to send the message as a reply to an existing message. |
bg_color | String | Optional | Background colour for the message bubble. |
echo | Integer | Optional | 1 returns a copy of the sent message to you. Default 0. |
web_page_preview | Integer | Optional | 1 disable preview Β· 2 hide the link Β· 3 instant view Β· 4 instant view without the link. |
disable_notification | Boolean | Optional | Deliver silently β the user gets no notification sound. |
menu_id | String | Optional | Show an existing predefined Chat Menu inline beneath the message. |
menu_ref | String | Optional | Reference of an existing menu to attach. This is what the SDK helpers set. |
inline_menu | Array of Menu | Optional | Attach a menu defined inline. Takes priority over menu_ref if both are set. |
chat_settings | Integer | Optional | 1 routes the message to the Bot Manager, used for admin-only communication. |
schedule_date | Long | Optional | Send later β Unix epoch in milliseconds. See Scheduled Messages. |
Preconditions
Your API needs the right permission, and the right standing in the chat.
Requirement | Needed for |
"Send Message" permission | Sending at all. |
"Reply to Message" permission | Only when using reply_to_message_id. |
Chat type | Your API must be |
--- | --- |
User chat | Already started by the user |
Group | A member |
Channel | An admin |
Response
When | Method | What it tells you |
Always | messageAck | The server accepted the message. Carries the new message_id and echoes your reference. |
If echo = 1 | message | A full copy of the message as it was sent. |
User chats only | messageDelivered | The user's device received it. |
User chats only | messageSeen | The user opened it. |
SDKs
SDK | Call | Callback |
Java | api.sendText(chatId, text, reference, appId); | onMessagAckCallback(MessageAck msgAck) |
JavaScript | api.sendText(chatId, text, reference, appId); | onMessagAckCallback(msgAck) |
Python | napi.send_text(chat_id=chat_id, text=text, reference=reference, app_id=app_id) | on_message_ack_callback(self, msg_ack) |
Example
Request
json{ "method": "sendMessage", "chat_id": "90089584764538542", "text": "Hello World!", "reference": 111111125, "app_id": "90090684293000559", "echo": 1 }
javaapi.sendText(chatId, text, reference, appId);
javascriptapi.sendText(chatId, text, reference, appId);
pythonnapi.send_text(chat_id=chat_id, text=text, reference=reference, app_id=app_id)
Response
json{ "method": "messageAck", "ack": { "reference": 111111125, "date": 1741955529668, "gmid": null, "message_id": "d1_Etk9FYKc126178" } }
And, because
echo was 1:json{ "method": "message", "app_id": 90090684293000559, "message": { "message_id": "d1_Etk9FYKc126178", "reference": 111111125, "date": 1741955529668, "type": "text", "text": "Hello World!", "chat": { "id": "90091783822039252", "name": "MY First API", "type": "Bot", "terminal": "API" }, "sent_to": { "id": "90089584764538542" }, "from": { "id": "90091783822039252", "name": "My First API", "type": "Bot", "terminal": "API" } } }
When the text exceeds 1800 characters
The request is identical. The delivered message comes back with
"type": "text_file", a truncated text, and the full body as a downloadable file:json{ "method": "message", "message": { "message_id": "d1_3NMolOz0126187", "type": "text_file", "text": "Lorem ipsum dolor sit amet ... (first 1800 characters)", "text_file": { "id": "null7846edb10b41a5b11fac74ab0699b4f56b956c7e247b90c590f311d6bee8a35b.txt", "size": 12162 } } }