Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline keyboard without URL, just text #424

Closed
dehghani-mehdi opened this issue Sep 25, 2017 · 4 comments
Closed

Inline keyboard without URL, just text #424

dehghani-mehdi opened this issue Sep 25, 2017 · 4 comments

Comments

@dehghani-mehdi
Copy link

Seems like url parameter is optional in inline keyboard ref, but I could not use inline keyboard without that.

Bug Report

I have read:

I am using the latest version of the library.

Expected Behavior

Can use inline keyboard without url

Actual Behavior

I got this error message:

Can't parse inline keyboard button: Text buttons are unallowed in the inline keyboard

Steps to reproduce the Behavior

Sample code:

bot.sendMessage(msg.chat.id, 'Hello', {
        reply_markup: {
            inline_keyboard: [
                [{
                    text: 'my button'
                }]
            ]
        }
    });

With url code works.

bot.sendMessage(msg.chat.id, 'Hello', {
        reply_markup: {
            inline_keyboard: [
                [{
                    text: 'my button',
                    url: 'www.somewhere.com'
                }]
            ]
        }
    });

Thanks.

@alexandercerutti
Copy link
Contributor

Use an empty callback_data in text button. That should work.

{
    reply_markup: {
        inline_keyboard: [
            [{
                text: "my button",
                callback_data: "",
             }]
        ]
    }
}

@antonio7905
Copy link

According to Telegram Official Bot API,

InlineKeyboardButton
This object represents one button of an inline keyboard. You must use exactly one of the optional fields.

You need to choose one from url, callback_data , switch_inline_query , switch_inline_query_current_chat , callback_game , pay.

@dehghani-mehdi
Copy link
Author

@alexandercerutti your code doesn't work, but helped me, thanks. working code is as follow:

{
    reply_markup: {
        inline_keyboard: [
            [{
                text: "my button",
                callback_data: "whatever",
             }]
        ]
    }
}

@alexandercerutti
Copy link
Contributor

Well, okay, I wrote it without watching the documentation ahah. You are welcome 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants