Google cloud firestore agent.add不工作,但console.log工作

Google cloud firestore agent.add不工作,但console.log工作,google-cloud-firestore,dialogflow-es,actions-on-google,dialogflow-es-fulfillment,Google Cloud Firestore,Dialogflow Es,Actions On Google,Dialogflow Es Fulfillment,在下面的代码中,“agent.add”不起作用,但“console.log”起作用。我以坚定和拒绝的态度加入了承诺,但它仍然不起作用。我尝试了不同的方法,但firestore有多个响应,无法将其发送给用户。能够在firebase中查看日志,但不能在dialogflow中查看日志 const {Firestore} = require('@google-cloud/firestore'); const functions = require('firebase-functions'

在下面的代码中,“agent.add”不起作用,但“console.log”起作用。我以坚定和拒绝的态度加入了承诺,但它仍然不起作用。我尝试了不同的方法,但firestore有多个响应,无法将其发送给用户。能够在firebase中查看日志,但不能在dialogflow中查看日志

    const {Firestore} = require('@google-cloud/firestore');
    const functions = require('firebase-functions');
    const {WebhookClient} = require('dialogflow-fulfillment');
    const {Card, Suggestion} = require('dialogflow-fulfillment');
    const admin = require('firebase-admin');

    admin.initializeApp();

    process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging 
     statements
        const firestore = new Firestore();
        const settings = {/* your settings... */ 
                          timestampsInSnapshots: true};
    firestore.settings(settings);

    exports.dialogflowFirebaseFulfillment = 
     functions.https.onRequest((request, response) => {
      const agent = new WebhookClient({ request, response });
      console.log('Dialogflow Request headers: ' + 
     JSON.stringify(request.headers));
      console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
     const db = admin.firestore();

    ```
    function welcome(agent) {
      agent.add(`Welcome to my agent!`);  // not working
      console.log("Welcome Agent");
      const num = agent.parameters.number;

      let usersRef = db.collection('add');
      let query = usersRef.where('Number', '==', num);
      return new Promise((resolve,reject)=>{   // not working
        return query.get()
          .then(querySnapshot => {
            if (querySnapshot.empty) {/*
            const timestamp = querySnapshot.get('created_at');
            const date = timestamp.toDate();*/
              console.log('No matching documents.');
              agent.add(`No Matching Documents`);
              return;
            }
            querySnapshot.forEach(doc => {
              const line1 = doc.get('Line1');
              const line2 = doc.get('Line2');
              const explain = doc.get('explanation');
              console.log('Line1: ', line1);  //this works
              console.log('Line2: ', line2);  //this works
              console.log('explain: ', explain); //this works
              agent.add(`your response is ` +doc.get('Line1')); //not working
              agent.add(`Final Response -  ${line2}`); //not working
              agent.add(doc.get('explanation')); //not working
            });
            resolve('resolved');
          })
          .catch(err => {
            console.log('Error getting documents', err);
            reject(err);
          });
      });
    }


问题现在解决了。在最后一个agent.add中添加了return语句,它正在工作。谢谢

agent.add(your response is +doc.get('Line1')); 
agent.add(Final Response - ${line2}); 
return agent.add(doc.get('explanation')); 

当你说“不起作用”时,你是如何测试它是否起作用的?你在什么地方出错了吗?如果这是通过模拟器完成的,您能否更新您的问题以显示模拟器显示的内容?您正在使用哪个库(或显示其余代码以显示正在加载的库以及如何注册意图处理程序)?@Captive,我正在dialogflow中测试它,获得“默认响应”不可用,但在firebase控制台日志中,我能够看到日志正确填充。能够看到欢迎意图被触发。添加了代码..问题现在已解决。在最后一个agent.add中添加了return语句,它正在工作。谢谢agent.add(
您的响应是
+doc.get('Line1'));add(
Final Response-${line2}
);退货代理添加(单据获取(‘解释’);我正在尝试分析履行的执行情况,但
console.log
s未显示在任何日志中。我该怎么办?