Build bots for KyaChat
Bots are KyaChat accounts run by your code. They chat with people, post to channels and offer buttons for orders, bookings and reminders.
Three steps to a working bot
Create the bot
In KyaChat Web, open Settings, then Bots. Choose a name and an @username. KyaChat shows the bot’s token once, so copy it somewhere safe.
Get updates
Call
getUpdatesto collect new messages and button taps, or callsetWebhookand KyaChat posts them to your HTTPS server.Reply
Answer with
sendMessage, add buttons withreply_markup, and update the message later witheditMessageText.
One HTTPS call per action
Create a bot in Settings, then send messages, buttons, photos and files over a simple HTTPS API. Collect updates with long polling or a webhook.
$ curl https://api.kyachat.org/bot$TOKEN/sendMessage \ -H 'Content-Type: application/json' \ -d '{ "chat_id": 2, "text": "4 orders are waiting for packing.", "reply_markup": {"inline_keyboard": [[ {"text": "Mark all packed", "callback_data": "packed"}, {"text": "Show orders", "callback_data": "orders"} ]]} }' {"ok":true,"result":{"message_id":8,...}}

Methods
Every method takes JSON, a form or query parameters at https://api.kyachat.org/bot<token>/<method> and answers JSON.
getMeCheck the token and read the bot’s own profile.
sendMessageSend text with optional formatting, a reply and buttons.
editMessageTextChange the text and buttons of a message the bot sent.
deleteMessageRemove a message the bot sent, or one it may moderate.
sendPhotoSend a photo with an optional caption.
sendDocumentSend any file up to 25 MB.
getUpdatesCollect new messages and button taps with long polling.
setWebhookHave updates posted to your HTTPS server instead.
deleteWebhookStop webhook delivery and go back to polling.
Good to know
- The token is shown once and stored only as a hash. Rotate it in Settings and the old one stops working at once.
- A bot can write to someone only after that person has messaged it. In groups and channels it must be a member.
- Up to 120 calls every 10 seconds per bot. Above that the API answers 429 with a
retry_aftervalue. - Webhooks must use HTTPS, are retried with back-off when your server fails, and can carry a secret you check on every request.
- In a group a bot receives every message, so tell members what your bot does with them.
- Up to 20 bots per person.