pythonpython-3.xvk

Vk chat bot with python + vk_api


I am trying to do vk chat bot, but have an exception

import vk_api
import time
import json

token = 'ea8d297a7***3fd45e98fd0f2b0215954d854a0'
vk = vk_api.VkApi(token=token)
vk._auth_token() # vk.auth() doesn't work

print(  # Getting chat info
        vk.method('messages.getConversations')
        )
keyboard = {'one_time':True,
            'buttons':
            [
                [
                    {'action':
                        {'type':'text', 
                        'label':'This is keyboard!'},
                    'color':'Positive',
                    }
                ]
            ]
            }
my_id = vk.method('messages.getConversations')['items'][0]['last_message']['from_id']
# my_id - id of the last message in the chat
vk.method('messages.send', 
            {'user_id':my_id, 
            'message':'Keyboard to the studio!',
            'keyboard':str(json.dumps(keyboard))
            })

vk_api.exceptions.ApiError: [912] This is a chat bot feature, change this status in settings

vk.method('messages.send', ..... occurs it. I want to send user message with keyboard. How can I do it and why this error occurs? Thanks for any help!


Solution

  • You should go to "Community Management" - > "Messages" - > "Bot Settings" and enable " bot features"