我正在使用此代码从 Node.JS Dialogflow CX webhook 发回文本响应。我想播放音频作为履行,所以我想发回该音频的链接。
如何发回音频文件链接?
const express = require("express");
const app = express();
const bodyParser = require("body-parser");
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: false
}));
app.post("/webhook", (request, response) => {
let tag = request.body.fulfillmentInfo.tag;
let jsonResponse = {};
if (tag == "hello") {
//fulfillment response to be sent to the agent if the request tag is equal to "welcome tag"
jsonResponse = {
fulfillment_response: {
messages: [{
text: {
//fulfillment text response to be sent to the agent
text: ["Hi! This is a webhook response"]
}
}]
}
};
} else {
jsonResponse = {
//fulfillment text response to be sent to the agent if there are no defined responses for the specified tag
fulfillment_response: {
messages: [{
text: {
////fulfillment text response to be sent to the agent
text: [
`There are no fulfillment responses defined for "${tag}"" tag`
]
}
}]
}
};
}
response.json(jsonResponse);
});
const listener = app.listen(3000, () => {
console.log("Your app is listening on port " + listener.address().port);
});