A
A
Alexander Muradov2020-05-13 17:29:37
Python
Alexander Muradov, 2020-05-13 17:29:37

How to create a VKontakte conversation using Vk Api?

When using the createChat function, the peer_id of the created conversation is returned, but it is not displayed in the group itself. But, when calling the getConversationsById function, I can see information about it. And when you call getInviteLink, an error 100 is issued, supposedly this is not a conversation at all. I don’t understand how to create a VKontakte conversation using the Vk Api?

def createChat():
return vk_session.method('messages.createChat',
values={'user_ids': 'user_ids', 'title': '1234', 'group_id': group_id})

def getConversationsById(peer_id):
return vk_session .method('messages.getConversationsById',
values={'peer_ids': 2000000000 + peer_id, 'group_id':

vk_session.method('messages.getInviteLink', values={'peer_id': peer_id, 'group_id': group_id})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Lebedinsky, 2020-05-13
@zank

Shalom
Creating a conversation is as follows:

peer = event.peer_id
id_chat = vk.method('messages.createChat', {'user_ids': '*11111111,2222222', 'title': 'Test', 'group_id': peer})

*IDs of users to include in the conversation. (separated by commas)
After that, we should get a link to the conversation, for this we execute the following piece of code:
link_chat = vk.method('messages.getInviteLink', {'peer_id': '**2000000004', 'reset': '1', 'group_id': *11111111})
print(link_chat)

Print(link_chat) and there will be your link to invite to the conversation. The main thing is that a new link is not generated every time, change the parameter "reset": 1 to "reset": 0.
* Group ID without the "-" sign
** This is the ID of the created conversation, to get it, take the resulting number with the variable id_chat and add to her 2000000000.

5ebc602da5ef7804803681.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question