我想在dialogflow中运行此代码,基本上我想使用if条件例如。如果我的意图是“完成”,请回复[文本回复] =>“现在再添加2个并说得到它”它切换到我的另一个意图,即“正确”,因此响应应该是“ you no。is 1”,并结束转换。相似点如果我的意图是“完成”,请回复[文本回复] =>“现在再添加4个并说得到它”,然后它切换到我的另一个意图,即“正确”,因此响应应该是“ you no。is 2”并结束转换。
然后继续。
只需看下面的SSenter image description hereenter image description here
'use strict';
// Import the Dialogflow module from the Actions on Google client library.
const {dialogflow} = require('actions-on-google');
// Import the firebase-functions package for deployment.
const functions = require('firebase-functions');
// Instantiate the Dialogflow client.
const app = dialogflow({debug: true});
var numr=0;
app.intent('done',(conv,output)=>{
if(conv.ask ==='Now add 2 more, and say got it'){
numr=1;
return numr;
}
else{
numr=2;
return numr;
}
});
app.intent('Alright',(conv)=>{
conv.close('your number is '+ numr);
});
// Set the DialogflowApp object to handle the HTTPS POST request.
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
您的代码存在许多问题,很难准确地了解您在做什么。但是,有几件事要注意。我假设您在这里使用JavaScript。