Невозможно добавить фишки для предложений в google assistant inline по конкретному назначению - PullRequest
0 голосов
/ 09 ноября 2018

Я реализовал код, который работает нормально, но как только я начал добавлять код с 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 голосов
/ 09 ноября 2018

Добавление предложений выполняется с помощью объекта 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'] ) );
});
...