Z
Z
zonf1k2020-02-14 19:44:26
JavaScript
zonf1k, 2020-02-14 19:44:26

How to process Payload in VK Bot?

cmd.hear(/^(?:Начать)$/i, async message => {
    vk.api.call('messages.send', {
        user_id: message.senderId,
        random_id: 0,
        message: `Вы находитесь в Главном меню`,
        keyboard: JSON.stringify(
            {
                "one_time": false,
                "inline": false,
                "buttons": [
                    [{
                        "action": {
                            "type": "text",
                            "payload": "{\"button\": \"1\"}",
                            "label": 'FAQ'
                        },
                        "color": 'positive'

                    }]
                ]
            })
     })
});


How do I process the Payload (I don't know much)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stockholm Syndrome, 2020-02-14
@zonf1k

vk.updates.on('new_message', (ctx) => {
  if (ctx.messagePayload.button == 1) {
    // ...
  }
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question