I am using Node.js telegram-bot-api.
Idea:
- Show a custom keyboard with one button – “Share my phone number”.
- When user clicks this button, contact should be sent and button should be removed from screen.
Here is a code I am using right now:
bot.sendMessage({
text: 'Please give us your phone number',
reply_markup: JSON.stringify({
keyboard: [
[{
text: 'Share my phone number',
request_contact: true
}]
],
resize_keyboard: true,
one_time_keyboard: true
})
});
Problems:
- When user clicks “Share my phone number” button, it shares his contact but button is visible even after that.
- When I am not using
request_contact
flag,one_time_keyboard
works correctly (hides the button after its usage), but even in that case it just hides the button, so user can click an icon to bring it back to screen, which is not good at all.
Please tell me if I am doing something wrong here. Thanks
3
Answers
Found it.
Here is a solution:
You should use
editMessageReplyMarkup
and update that message’sreplyMarkup
with null string(''
) after client user’s click recieved.UPDATE this is applicable for inline keyboards.
hide_keyboard
has been renamed toremove_keyboard
since API 2.3.