- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为我的 Facebook 页面设置聊天机器人,并使用 Google Dialogflow 处理对话。
对于特定的 Intent,我需要发送 2 个响应。
我了解,对于单个 Intent,我无法通过 Fulfillment 代码发送第一个响应,也无法通过 Dialogflow 控制台 UI 发送第二个响应设置。因此,我需要编写代码来发送这两个响应。
我能够发送第一个响应。但无法发送 Rich 消息内容。 DialogFlow 文档显示了代码片段,但不清楚来自不同页面的代码片段如何适合它。
这是我的代码(只是发布 actionHandlers)试图发送一个语句和一个音频(https://dialogflow.com/docs/rich-messages#custom_payload)
const actionHandlers = {
'input.welcome': () => {
const speechText = 'Hi ' + userProfile['first_name'] + ', This is Eva, digital assistant of LMES Academy. Since my people are busy working on the content for the next video, I\'d like to help you with your needs 😃';
const responsePayload = {
'speech': speechText,
'outputContexts': [{
'user-name': userProfile.first_name
}],
"data": {
"facebook": {
"attachment": {
"type": "audio",
"payload": {
"url": "http://incompetech.com/music/royalty-free/mp3-royaltyfree/Funk%20Game%20Loop.mp3"
}
}
}
}
};
sendResponse(responsePayload);
},
// The default fallback intent has been matched, try to recover (https://dialogflow.com/docs/intents#fallback_intents)
'input.unknown': () => {
sendResponse('I\'m having trouble, can you try that again?'); // Send simple response to user
}
};
文本响应有效,但 Audio
无效。我做的对吗?任何帮助表示赞赏。
更新 1: 在更改 mp3 链接后,音频可以正常工作。但是文本响应不起作用。
发送到我的云函数中的 response.json()
的对象的日志。
{
"speech": "Hi Saiyasodharan, This is Eva, digital assistant of LMES Academy. Since my people are busy working on the content for the next video, I'd like to help you with your needs 😃",
"displayText": "Hi Saiyasodharan, This is Eva, digital assistant of LMES Academy. Since my people are busy working on the content for the next video, I'd like to help you with your needs 😃",
"data": {
"facebook": {
"attachment": {
"type": "audio",
"payload": {
"url": "http://66.90.93.122/ost/death-note-original-soundtrack/bowkqzxs/01%20Death%20note.mp3"
}
}
}
},
"contextOut": [{
"user-name": "Saiyasodharan"
}]
}
在上面的代码中,我期望
displayText
立即显示 -> 不起作用audio
响应发生 -> 更改 mp3 链接后,现在可以正常工作了我相信我需要通过 data
属性提供文本响应和音频响应。让我在这里尝试更新。
最佳答案
如果您对给定集成使用负载,则响应文本将被忽略。您需要将具有属性 text
的消息添加到 facebook
有效负载,以便它显示在 Facebook Messenger 中。例如:
{
"contextOut": [
{
"user-name": "Saiyasodharan"
}
],
"data": {
"facebook": {
"attachment": {
"payload": {
"url": "http://66.90.93.122/ost/death-note-original-soundtrack/bowkqzxs/01%20Death%20note.mp3"
},
"type": "audio"
},
"text": "Hi Saiyasodharan, This is Eva, digital assistant of LMES Academy. Since my people are busy working on the content for the next video, I'd like to help you with your needs 😃"
}
},
"displayText": "Hi Saiyasodharan, This is Eva, digital assistant of LMES Academy. Since my people are busy working on the content for the next video, I'd like to help you with your needs 😃",
"speech": "Hi Saiyasodharan, This is Eva, digital assistant of LMES Academy. Since my people are busy working on the content for the next video, I'd like to help you with your needs 😃"
}
关于google-cloud-functions - 对话流 : Posting attchment to Facebook via Fullfillment via Firebase (inline) Cloud functions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49153051/
我正在为我的 Facebook 页面设置聊天机器人,并使用 Google Dialogflow 处理对话。 对于特定的 Intent,我需要发送 2 个响应。 包含用户名的常规语句。 具有 3 个按钮
我是一名优秀的程序员,十分优秀!