我尝试使用 SSML 播放小尺寸音频,但下面的代码抛出错误“expected_inputs[0].input_prompt.rich_initial_prompt.items[0].simple_response: 'display_text' must be set or 'ssml' must have a valid display渲染。”
// See https://github.com/dialogflow/dialogflow-fulfillment-nodejs
// for Dialogflow fulfillment library docs, samples, and to report issues
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const {
MediaObject
} = require('actions-on-google');
const LOGO_IMG = 'https://s3.ap-south-1.amazonaws.com/XXXXXXXXXXXXXX/skill/Logo1200.jpg'
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
function welcome(agent) {
agent.add(new Card({
title: `TITLE`,
imageUrl: LOGO_IMG,
text: `This is the body text of a card. You can even use line\n breaks and emoji! `
})
);
const welcomeText = 'Welcome message';
agent.add(welcomeText);
}
function playsong(agent) {
agent.add('<speak> <audio src="https://actions.google.com/sounds/v1/alarms/alarm_clock.ogg"></audio></speak>');
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('PlaySongIntents', playsong);
intentMap.set('Default Fallback Intent', fallback);
// intentMap.set('your intent name here', yourFunctionHandler);
// intentMap.set('your intent name here', googleAssistantHandler);
agent.handleRequest(intentMap);
});