botman / driver-telegram

BotMan Telegram Driver
MIT License
86 stars 75 forks source link

Not working callback_data in menu #104

Open falur opened 2 years ago

falur commented 2 years ago

Description:

Not working callback_data bot sends text

Steps To Reproduce:


$bot->reply(
    "👉🏼 Menu👇🏽",
    [
            'reply_markup' => json_encode([
                'keyboard' => [
                    [
                        [
                            'text' => 'Фотогалерея 🖼',
                            'callback_data' => '/photos',
                        ],
                        [
                            'text' => 'Планировки 📐',
                            'callback_data' => 'plans',
                        ],
                    ],
                    [
                        [
                            'text' => 'Характеристики ЖК 🏣',
                            'callback_data' => 'characteristics',
                        ],
                        [
                            'text' => 'Расположение ⛳️',
                            'callback_data' => 'place',
                        ],
                    ],
                    [
                        [
                            'text' => "Скачать прайс  ₽",
                            'callback_data' => 'price',
                        ],
                        [
                            'text' => 'Записаться на показ 📞',
                            'callback_data' => 'write-on-show',
                        ],
                    ],
                    [
                        [
                            'text' => 'Получить консультацию 📞',
                            'callback_data' => 'consultation',
                        ],
                        [
                            'text' => 'Акции  %',
                            'callback_data' => 'sales',
                        ],
                    ],
                ],
            ]),
        ]
 )```
Darkrogua commented 1 year ago

faced the same problem did you find a solution?

falur commented 10 months ago

I did not find solution (

antimech commented 9 months ago

Learn the difference between the two types of Telegram Bot Keyboards: https://core.telegram.org/bots/api#keyboardbutton https://core.telegram.org/bots/api#inlinekeyboardbutton

What you want is probably to replace 'keyboard' with 'inline_keyboard'. If not, then delete 'callback_data' and catch the 'text' with $botman->hears('Фотогалерея 🖼') at the webhook. In case you use Laravel it's a good idea to use the internal __('') method to avoid text duplication.