D
D
Duzive2019-09-20 19:16:29
Python
Duzive, 2019-09-20 19:16:29

The bot does not send the keyboard, but gives an error. How to fix?

I decided to add a keyboard to the bot. Wrote a function that creates a keyboard skeleton:

def get_button(label, color, payload=""):
  return { 
  "action": {
                    "type": "text",
                    "payload": json.dumps(payload),
                    "label": label
  },
  "color": color
}

After that, I put the notation for the keyboard:
keyboard = {

"one_time": True,
"Buttons": [

  [
  get_button(label="Кнопка 1", 	color="positive"),
  get_button(label="Кнопка 2", color="positive"),
  get_button(label="Кнопка 3", color="positive"),
  get_button(label="Кнопка 4", 	color="negative"),
  ]

  ]
}

keyboard = json.dumps(keyboard, ensure_ascii=False).encode('utf-8')
keyboard = str(keyboard.decode('utf-8'))

Then I designate it in "message.send"
But after launch, I get the following error:
5d84fb257d988414225426.jpeg
How to fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question