From 88886646ec7bcffe3203d398d1eb30d69848e6b9 Mon Sep 17 00:00:00 2001 From: ndrbrt Date: Sun, 8 Jan 2017 16:41:05 +0100 Subject: [PATCH] Update messenger.py I tried to send an audio message to my bot and the chat stopped working because a KeyError were raised (no key 'text', since it wasn't a text message). This should solve the problem. --- examples/messenger.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/messenger.py b/examples/messenger.py index 7474fb4..a8af08e 100644 --- a/examples/messenger.py +++ b/examples/messenger.py @@ -69,7 +69,10 @@ def messenger_post(): # We retrieve the Facebook user ID of the sender fb_id = message['sender']['id'] # We retrieve the message content - text = message['message']['text'] + if 'text' in message['message']: + text = message['message']['text'] + else: + text = '' # Let's forward the message to the Wit.ai Bot Engine # We handle the response in the function send() client.run_actions(session_id=fb_id, message=text)