【问题标题】:unable to get user's response in assisstant on firebase cloud function无法在 Firebase 云功能助手中获得用户响应
【发布时间】:2018-06-08 21:55:20
【问题描述】:

我需要一个帮助,我没有在对话流 Firebase 函数中得到用户的响应。请在 index.js 中找到编码 在 TestIntent 中,我想获得用户的响应(用户回答),我尝试使用 "app.intent('Test Intent',(conv,input)" ,并在 "ask" 中使用 "${input}"。现在我尝试使用“app.intent('Test Intent',(conv,params)”,但没有收到用户的回复。请告诉我,如何获得用户的回复”

import * as functions from 'firebase-functions';
import * as gApp from 'actions-on-google';
import { myService } from './services/myService';
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
import admin from 'firebase-admin';
const app = gApp.dialogflow({debug: true});

process.env.DEBUG = 'dialogflow:debug'; 

//exports.dialogflowSample = functions.https.onRequest((request, response) => 
//{


  app.intent('Default Welcome Intent',(conv) => {
    conv.ask(`Welcome to my dialogFlow agent! <say-as >${input}</say-as>.</speak>`);
    //conv.data.question = 'question1';

  });


app.intent('Test Intent',(conv,params) => {
    let qNo:string  =   conv.data.question;
    conv.ask('<speak>Testing the application'
    +`<say-as >`+conv.params.pain+`</say-as>.</speak>`);
    conv.ask('<speak>Testing the application'+`<say-as >`+qNo+`</say-as>.</speak>`);
    });

  exports.dialogflowSample = functions.https.onRequest(app);
//});

【问题讨论】:

    标签: firebase google-cloud-functions actions-on-google dialogflow-es


    【解决方案1】:

    如果您想准确返回用户所说的内容,您可以这样做:

    app.intent('Test Intent',conv => {
        let userRawInput  =   conv.input.raw;
        conv.ask("You said exactly: "+userRawInput);
        });
    

    【讨论】:

    • 如果我使用 google home 进行测试,我会在 "conv.input.raw" 中得到相同的值吗? ,,
    • 您是否有指南来引用 conv、actions-on-google..etc 中的所有对象引用。
    • 我所做的是打印conv对象并检查它的字段,然后我找到了我感兴趣的并使用它
    猜你喜欢
    • 2021-12-15
    • 1970-01-01
    • 1970-01-01
    • 2020-09-04
    • 2020-02-28
    • 2021-11-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多