【发布时间】:2018-01-22 12:20:34
【问题描述】:
我目前正在尝试向我在 Amazon Lambda 中使用 Amazon Lex 和 Python 开发的信使聊天机器人添加快速回复按钮。我在 Facebook 的开发者网站上找到了这个:
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"<PSID>"
},
"message":{
"text": "Here's a quick reply!",
"quick_replies":[
{
"content_type":"text",
"title":"Search",
"payload":"<POSTBACK_PAYLOAD>",
"image_url":"http://example.com/img/red.png"
},
{
"content_type":"location"
},
{
"content_type":"text",
"title":"Something Else",
"payload":"<POSTBACK_PAYLOAD>"
}
]
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=<PAGE_ACCESS_TOKEN>"
我已尝试搜索解决方案,但它们需要 fbmessenger 库。我希望使用 urllib 库而不是开源库。有解决办法吗?
Quick Reply Button in Messenger
def helpMe(intent_request):
session_attributes = intent_request['sessionAttributes'] if intent_request['sessionAttributes'] is not None else {}
return close(
session_attributes,
'Fulfilled',
{
'contentType': 'PlainText',
'content': 'It seems like you need help, let me save you from your misery.\n\n'
+ '- If you want to find '
+ 'out what insurance plan is suitable for your dear self, try asking me "Which integrated Shield Plan is right for me?".\n\n '
+ '- If you want me to explain about your current plan, you could try asking me '
+ '"Explain my current plan".\n\n '
+ '- If you wanna listen to my extremely hilarious puns, just type in "joke" and you will not regret it hehe. '
},
'responseCard': {
'version': '0',
'contentType': 'application/vnd.amazonaws.card.generic',
'genericAttachments': [
{
'title': 'Help',
'subTitle': 'Select button of choice',
'imageUrl': '',
"buttons":[
{
"text":"recommend plan",
"value":"Which integrated Shield Plan is right for me"
},
{
"text":"current plan",
"value":"Explain my current plan"
},
{
"text":"tell me a joke",
"value":"joke"
}
]
}
]
}
)
【问题讨论】:
标签: python amazon-web-services aws-lambda facebook-messenger amazon-lex