0

I am very new to bot development. I am playing wit.ai with facebook messanger. How do we set quick replies from action?

Ramesh Murugesan
  • 4,727
  • 7
  • 42
  • 67

1 Answers1

0

Here is how I do it:

if quick_replies:
    data['message']['quick_replies'] =[{'content_type': 'text', 'title': qr, 'payload': 'n/a'} for qr in quick_replies]
requests.post(FB_URL % 'me/messages', json=data, headers={'Content-Type': 'application/json'}).json()

I get the quick_replies list from Wit.ai, when it calls my send action. For example:

def send(request, response):
    fb.send_message(request['session_id'][32:], response['text'], response['quickreplies'] if ('quickreplies' in response) else None)
    return request['context']
Franco
  • 669
  • 2
  • 8
  • 23