使用python和webhook添加对dialogflow响应的快速答复

时间:2019-11-25 10:51:42

标签: python dialogflow-fulfillment

我试图使用我使用python的实现后端在对话框流响应中插入电报快速回复。

def results():

    quick_replies_list =['book appointment','list of doctors','locaton']
    title = "Hello and welcome."
    platform = "TELEGRAM"

    req = request.get_json()
    print(req)
    action = req.get('queryResult').get('action')

    if action =="input.welcome":
        result = req.get('result')
        #req = request.get_json(silent=True, force=True)
        result['quickReplies'] = quick_replies(platform, title, quick_replies_list)
        res = jsonfy(result)
        r = make_response(res)
        return r

def quick_replies(platform, title, quick_replies_list):
    quick_replies = []
    for quick_reply in quick_replies_list:
        # append to the list
        quick_replies.append(
            str(quick_reply)
        )
    return {
        "quickReplies": {
            "title": str(title),
            "quickReplies": quick_replies
        },
        "platform": platform
    }

0 个答案:

没有答案