rmoff's random ramblings
about talks

Telegram bot - BOT_COMMAND_INVALID

Published Jul 23, 2020 by in Telegram at https://rmoff.net/2020/07/23/telegram-bot-bot_command_invalid/

A tiny snippet since I wasted 10 minutes going around the houses on this one…

tl;dr: If you try to create a command that is not in lower case (e.g. Alert not alert) then the setMyCommands API will return BOT_COMMAND_INVALID

Create a command for your Telegram bot:

curl --location --request GET 'https://api.telegram.org/botMY_TOKEN/setMyCommands' \
--header 'Content-Type: application/json' \
--data-raw '{
    "commands": [
        {
            "command": "alert",
            "description": "Define an alert to be sent if a carpark becomes available with greater than the defined number of spaces"
        }
    ]
}'
{"ok":true,"result":true}

List commands for your Telegram bot:

curl --location --request GET 'https://api.telegram.org/botMY_TOKEN/getMyCommands'
{"ok":true,"result":[{"command":"alert","description":"Define an alert to be sent if a carpark becomes available with greater than the defined number of spaces"}]}

Robin Moffatt

Robin Moffatt works on the DevRel team at Confluent. He likes writing about himself in the third person, eating good breakfasts, and drinking good beer.

Story logo

© 2025