Answer the question
In order to leave comments, you need to log in
How to submit VK bot keyboard to node.js?
When writing a bot for the VK community, I encountered the need to send the bot's keyboard. To do this, the keyboard JSON object is passed as a string in the keyboard parameter in the messages.send method
vk.messages.send({
user_id: //id получателя
message: //текст сообщения
keyboard: //клавиатура в формате json
});
// клавиатура вида
// | Red | Green |
// | White | Blue |
keyboard:
{
"one_time": false,
"buttons": [
[{
"action": {
"type": "text",
"payload": "{\"button\": \"1\"}",
"label": "Red"
},
"color": "negative"
},
{
"action": {
"type": "text",
"payload": "{\"button\": \"2\"}",
"label": "Green"
},
"color": "positive"
}],
[{
"action": {
"type": "text",
"payload": "{\"button\": \"3\"}",
"label": "White"
},
"color": "default"
},
{
"action": {
"type": "text",
"payload": "{\"button\": \"4\"}",
"label": "Blue"
},
"color": "primary"
}]
]
}
Answer the question
In order to leave comments, you need to log in
You need to use JSON.stringify(keyboard), but vk-io has normal keyboard work :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question