O
O
ojiekcahdp2021-01-08 21:55:26
In contact with
ojiekcahdp, 2021-01-08 21:55:26

How to make the bot respond to the message, namely the answer (reply)?

I want a code so that the bot responds specifically to the message, that is, for example, a person writes hello, the bot answers hello but in response to the message, more understandably, reply.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Semin, 2021-01-11
@ojiekcahdp

From your comments, I understand that you are using the vk-io
library. Actually, now the code that you apparently need is:

vk.updates.hear(/(?:вопрос)/iu, msg => {
msg.send(`ответ`, {
  reply_to: msg.id
});
return;
})

But it will only reply to messages in private messages with the bot, so that the bot can reply to messages in conversations, you must use the forward parameter
vk.updates.hear(/(?:вопрос)/iu, msg => {
msg.send(`ответ`, {
forward: JSON.stringify({
  peer_id: msg.peerId,
  conversation_message_ids: [msg.conversationMessageId],
  is_reply: 1,
  })
});
return;
})

Z
ZIK1337, 2021-01-08
@ZIK1337

https://vk.com/dev/messages.send

reply_to
ID of the message to reply to

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question