Ali Qorbani
Ali Qorbani

Reputation: 1263

send inline keyboard for telegram bot in channel

Im trying to sendMessage using telegram bot api for showing inline keyboard

{
            "chat_id": "-1001751031382",
            "text": "test",
            "parse_mode": "Markdown",
            "disable_web_page_preview": true,
            "replay_markup": {
                "inline_keyboard": [
                    [
                        {
                            "text": "text1",
                            "url": "https://ali-qorbani.ir/1"
                        },
                        {
                            "text": "text2",
                            "url": "https://ali-qorbani.ir/2"
                        }
                    ],
                    [
                        {
                            "text": "start",
                            "url": "https://ali-qorbani.ir/4"
                        }
                    ]
                ]
            }
        }

url : https://api.telegram.org/bot{{token}}/sendMessage

but this only send message "test" without any inline_keyboard

how can I do that?

trying send inline keyboard for telegram bot

Upvotes: 0

Views: 83

Answers (1)

Actually there's one silly mistake.

{
    "chat_id": "-1001751031382",
    "text": "test",
    "parse_mode": "Markdown",
    "disable_web_page_preview": true,
    "replay_markup": {
        ^^^
        "inline_keyboard": [
            [
                {
                    "text": "text1",
                    "url": "https://ali-qorbani.ir/1"
                },
                {
                    "text": "text2",
                    "url": "https://ali-qorbani.ir/2"
                }
            ],
            [
                {
                    "text": "start",
                    "url": "https://ali-qorbani.ir/4"
                }
            ]
        ]
    }
}

It's not replay_markup instead, it should be reply_markup. Just a typo is what causing this issue.

Hope this helps!

Edit

One other thing I noticed is, the disable_web_page_preview parameter has been long gone. If you actually want to disable web page preview, you should use the link_preview_options parameter. It'll look something like this:

{
  "chat_id": "....",

  ...

  "link_preview_options": {
    "is_disabled": true,
  }

  ...
}

Happy coding!

Upvotes: 1

Related Questions