我无法在 node-wit messenger.js 示例中获得快速回复。 我尝试了可能的事情,包括: 1)更新了这行代码我们的机器人操作(messenger.js):
const actions = { send({sessionId}, {text,quickreplies})
2)并更新了这行代码我们的机器人操作(messenger.js):
return fbMessage(recipientId, text,quickreplies)
3)更新了我在messenger.js中的自定义操作:
getWelcome({context, entities})
{
context.welcome = "how are you. Please select from the options below";
context.welcome.quickreplies = [
{
title: 'Choice A',
content_type: 'text',
payload: 'empty'
},
{
title: 'Choice B',
content_type: 'text',
payload: 'empty'
},
]
return context;
},
4)我尝试了很多排列。我无法让它与 node-wit messenger.js 示例一起使用。没有显示快速回复我搜索并阅读了所有文档
5)你能帮忙解决这个问题吗?以及如何检索在messenger.js中选择的快速回复
谢谢
最佳答案
抱歉,如果来晚了,但我猜您正在寻找这个:
send(request, response) {
const {sessionId, context, entities} = request;
let {text, quickreplies} = response;
if(text.substring(0,6) === IDENTIFY_PAYLOAD){
text = text.substring(6); // It is a payload, not raw text
} else {
text = {"text": text};
}
if(typeof quickreplies !== "undefined"){
text.quick_replies = response.quickreplies
.map(x => { return {
"title": x, "content_type": "text", "payload": "empty"}
});
}
}
我所做的是发送一个带有字符串的有效负载,该字符串标识它不是原始文本(这就是为什么我使用有效负载的标识符),然后在发送操作中我收到两个参数请求和响应,并得到它们的属性。最后,我使用在互联网上找到的例程转换有效负载参数,实际上该例程可以很好地映射快速回复。
关于node.js - 快速回复 Node 编码 - 使用示例messenger.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43346250/