Dialogflow 添加动态文本不适用于 promise 和异步函数

Dialogflow adding dynamic text is not working with promise and async function

我正在尝试使用 add.agentuiFx 函数中获取更新后的消息变量。但是,both await 函数和 add.agent 一起存在问题。

var message = "hi"; //test purpose
async function GetCertain_info(agent) {

  console.log("1" + message);
  await uiFx(); *//this works fine in the console.log, and it updates the message*
  console.log("2" + message);
  agent.add("Here are the information on " + message);*//this works when the await uiFx() is removed and the message variable is returned as its initial value "hi"*
}

async function uiFx() {

  var {
    ui
  } = require('./uia.js');

  return new Promise(function(resolve, reject) {

    ui().then((msg) => {
      console.log("Destination Message :  " + msg)
      message = msg;
      resolve(message);

    }).catch((msg) => {
      console.log(msg)
      message = msg;
      reject(message);
    })
  });
}

似乎是什么问题以及如何解决?

感谢您的帮助

我发现问题是 uiFx() 需要超过 5 秒才能完成任务(对话流限制 - 5 秒)。此代码工作正常,但需要等待超过限制数量才能正确执行。