无法根据特定意图在Google Assistant内联中添加建议筹码

时间:2018-11-09 06:02:14

标签: javascript error-handling actions-on-google

我已经实现了代码,可以正常工作,但是一旦我开始使用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);

1 个答案:

答案 0 :(得分: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'] ) );
});