I have a bot code in Python, how can I add a keyboard there

There is a bot for vk written in Python, I want after the command "Hello", the keyboard was called, but I do not understand how it can be implemented.

Here is the code:

import time
import random
import json

#Токен
token = "943c0971e8904c9e2751549113df1c78378f6e6bb739ce4b8b0aa9b2d8236f884ce9b7e678652df86a8a3"

#Регестрация
vk = vk_api.VkApi(token=token)

vk._auth_token()

#Список приветствий
greetings = {'привет', 'здравствуй','ку','хелло','прив','начать','хай'}
#Команды
commands = ['случайное тз']

#Основной цикл
while True:
    try:
        messages = vk.method("messages.getConversations", {"offset": 0, "count": 20, "filter": "unanswered"})
        if messages["count"] >= 1:
            id = messages["items"][0]["last_message"]["from_id"]
            body = messages["items"][0]["last_message"]["text"]
            #Ответ на приветствия
            if body.lower() in greetings:
                vk.method("messages.send", {"peer_id": id, "message": "Привет!", "random_id": random.randint(1, 2147483647)})
            #Случайное ТЗ
            elif body.lower() in commands[0]:
                vk.method("messages.send", {"peer_id": id, "message": "Cкоро тут будут ТЗ", "random_id": random.randint(1, 2147483647)})
            #Неправильная команда
            else:
                vk.method("messages.send", {"peer_id": id, "message": "Не понял тебя!", "random_id": random.randint(1, 2147483647)})
    except Exception as E:
        time.sleep(1)```
Author: YFrite, 2020-05-25

1 answers

The keyboard is sent as a message to the user. In this case, the text of the message must also be

For convenience, you can use the module vk_api

The keyboard itself is an object vk_api.keyboard.Keyboard

On github, there is a beautiful example of using the keyboard

Moreover, I do not advise you to shine your token in the questions

 0
Author: dhvcc, 2020-05-25 15:52:59