A
A
aassww2020-12-31 23:03:09
In contact with
aassww, 2020-12-31 23:03:09

How to send information from a profile using the vk-io library?

I need to know the first and last name of the profile that writes to my bot so that it can address it by name. For example: (bot) Hello, Dmitry!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Semin, 2020-12-31
@thewayofmagic

To get a user profile, you can use the VK
users.get
API method Example:

const {VK} = require(`vk-io`);
const vk = new VK({token: "token"});

vk.updates.on("message", async function (context) {
if (message.isOutbox) {
return;
}
let [userData]= await vk.api.users.get({user_id: context.senderId});
return context.send(`Привет, ${userData.first_name}`);
});

vk.updates.startPolling();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question