Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question