2

我已经实现了代码,它工作正常,但是一旦我开始使用 addSugestions 添加代码,就会发生错误。请在这里的任何人通过 index.js 与代码实现分享您的知识

'use strict';

//Import the Dialogflow module from the Actions on Google client library//

const {dialogflow} = require('actions-on-google');

//Import the firebase-functions package//

const functions = require('firebase-functions');

//Instantiate the Dialogflow client//

const app = dialogflow({debug: true});

//Handle the create_name intent//

app.intent('create_name', (conv, {name}) => {

    //Construct the conversational response//

    conv.ask('Nice to meet you ' + name + '. Would you like to hear a joke?');
});




app.intent('create_yes', (conv) => {

    //Construct the conversational response//

    //conv.ask('Nice to meet you. Would you like to hear a joke?').addSuggestions(['0', '42', '100', 'Never mind']);

    conv.ask('Nice to meet you. Would you like to hear a joke?');
});





//Set the DialogflowApp object to handle the HTTPS POST request//

exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
4

1 回答 1

1

添加建议是使用Suggestions您添加的对象完成的conv.add()

像这样的东西:

const {dialogflow,Suggestions} = require('actions-on-google');

// ...

app.intent( 'suggest', conv => {
  conv.add( 'Here are some suggestions' );
  conv.add( new Suggestions( ['one','two','whatever'] ) );
});
于 2018-11-09T13:54:27.807 回答