有没有办法动态地激活一个dialogflow意图? [英] is there a way to activate a dialogflow intent dynamically?

查看:54
本文介绍了有没有办法动态地激活一个dialogflow意图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法可以动态激活意图,一种
满足此条件,而不是转到意图XX。
我试图解释我想做的事情:
当用户说出一个特定的单词时,该意图会在数据库中查找根据优先级算法要执行的任务。例如,如果选择任务1作为最高优先级,那么我应该能够激活在运行时任务1的意图,而无需要求用户说请说001激活任务1。
预先感谢

I wonder if there's a way to activate dinamically an intent, a sort of "it this condition is met, than goto intent XX". I try to explain what I'd like to do: when the user says a specific word, the intent looks up in the database what are the tasks to be done according to a priority algoritm. If for example task 1 is selected as topmost priority, then I should be able to activate "at runtime" task 1 intent, without asking the user to say "please say 001 to activate task 1" . Thanks in advance

推荐答案

我已经实现了您的请求,如果满足条件,则达到X意图通过将我的响应移动到不同的功能来实现。在以下情况下,我需要基于if条件的不同响应和不同输出上下文。通过这种方式,我可以根据用户输入动态触发不同的意图。

I've implemented your request for "if condition is met, got to X intent" in my webhook by moving my responses to different functions. In the case below, I want a different response and different output context based on an if condition. This way I can trigger different intents dynamically based on user input.

const game = SessionsService.getGame(userId);

if(game) {
  logger.info("Found a gamein progress..")
  const response = gameInProgress();
  conv.contexts.set("_defaultwelcomeintent-followup", 1);

  return conv.ask(response);
} else {
  logger.info("No game in progress found..")
  const response = welcome();
  conv.contexts.set("_introduction", 1);
  conv.contexts.set("_setup", 1);

  return conv.ask(response);
};

响应函数的示例:

function gameInProgress() {

  const text = messages.gameInProgressText();
  const ssml = messages.gameInProgressSsml();

  const response = new BasicResponse(text, ssml);

  return response;
};

代替boardService,您可以实现优先级算法。

Instead of the boardService, you could implement your priority algorithm.

这篇关于有没有办法动态地激活一个dialogflow意图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆