Answer the question
In order to leave comments, you need to log in
How to send only VK API keyboard?
The bot has several different keyboards, for different tasks, but you need the starting one to always be active. If you set the option "one_time": false, call another keyboard, select a function, after which the side keyboard will close, the main one will not open until you enter the keyword that should call it. Without thinking about a solution, I decided to try:
if event.object.text:
self.vk_api.messages.send(
user_id=event.object.from_id,
random_id=random.getrandbits(32),
message='',
keyboard=open("keyboard/start_keyboard.json", "r", encoding="UTF-8").read()
)
Answer the question
In order to leave comments, you need to log in
when the user clicks on the side keyboard, send not an empty message, but some "great choice" and return the old keyboard
Keyboard example
keyboard1234 = {
"one_time": True,
"buttons": [
[{
"action": {
"type": "text",
"payload": "{\"button\": \"1\"}",
"label": "Кнопка"
},
"color": "positive"
},
{
"action": {
"type": "text",
"payload": "{\"button\": \"2\"}",
"label": "Кнопка"
},
"color": "positive"
}]
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question