Interactive elements

Message keyboard

keyboard belongs to a message. Rows may have different widths; the maximum is 9 rows and 10 buttons per row.

Command autocomplete

The commands field defines suggestions shown after / is typed in a direct bot chat. command is the clean value inserted into the composer; arguments, description, and emoji icon are display-only hints. Omit the field to preserve the current list; send null or an empty array to clear it. The list syncs across the user’s devices.

{
  "commands": [
    { "command": "/start", "description": "Start again", "icon": "▶️" },
    { "command": "/invite", "arguments": "<email>", "description": "Invite a user" }
  ]
}

Button shape

command or action is required. text and emoji icon are optional, and long labels ellipsize. action.type defaults to send_command.

{
  "command": "/status",
  "text": "Status",
  "icon": "📦",
  "single_use": false,
  "expires_at": null
}

Actions

send_command posts a visible command, send_message posts specified text, callback emits an event without a user message, and open_url opens a confirmed HTTPS URL. Callback buttons show a loader while pending.

SDK practice

Commands create a visible user message; callbacks do not. Use callbacks for interface state and never place sensitive values in action.data.

Even with single_use enabled, make the server handler idempotent because duplicate network delivery can happen before the button is updated.

Usage examples

import { callbackButton, commandButton, urlButton } from '@keychat/bots';

await bot.sendMessage({ chat_id: chatId, content: {
  text: 'Choose an action',
  keyboard: { rows: [
    [commandButton('/status', { text: 'Status', icon: '📦' })],
    [callbackButton('details', 'Details', 'order-42'), urlButton('Help', 'https://example.com/help')]
  ] }
}});
© 2026. Key Chat.