javascript - 无法根据特定意图在谷歌助手内联中添加建议芯片

标签 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);

最佳答案

添加建议是通过 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'] ) );
});

关于javascript - 无法根据特定意图在谷歌助手内联中添加建议芯片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53220609/

相关文章:

javascript - 这是 JSFiddle 和 Codepen 或 Highcharts 中的错误,还是 Javascript 的限制?

javascript - 如何在 Javascript 中获得可读的语法错误?

go - Terratest 在错误断言上抛出错误

actions-on-google - 是否可以向 Google Home 设备发送语音通知

actions-on-google - "App isn' t installed“对于需要帐户链接的任何操作应用程序

javascript - insertRule 不插入样式元素

javascript - JS 的时间变化

php - 是否可以通过LAMP强制报告错误?

php - 带页面URL的PHP​​声明

actions-on-google - Google Actions/Dialogflow - 打开已安装的应用程序