有没有办法动态激活对话流意图?
is there a way to activate a dialogflow intent dynamically?
我想知道是否有办法动态激活一个意图,一种
"it this condition is met, than goto intent XX"。
我试着解释我想做什么:
当用户说出一个特定的词时,意图会根据优先级算法在数据库中查找要完成的任务。例如,如果任务 1 被选为最高优先级,那么我应该能够激活 "at runtime" 任务 1 意图,而无需要求用户说 "please say 001 to activate task 1" 。
提前致谢
我已通过将我的响应移动到不同的功能,在我的 webhook 中实现了你对 "if condition is met, got to X intent" 的请求。在下面的例子中,我想要基于 if 条件的不同响应和不同输出上下文。这样我就可以根据用户输入动态触发不同的意图。
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。
我想知道是否有办法动态激活一个意图,一种 "it this condition is met, than goto intent XX"。 我试着解释我想做什么: 当用户说出一个特定的词时,意图会根据优先级算法在数据库中查找要完成的任务。例如,如果任务 1 被选为最高优先级,那么我应该能够激活 "at runtime" 任务 1 意图,而无需要求用户说 "please say 001 to activate task 1" 。 提前致谢
我已通过将我的响应移动到不同的功能,在我的 webhook 中实现了你对 "if condition is met, got to X intent" 的请求。在下面的例子中,我想要基于 if 条件的不同响应和不同输出上下文。这样我就可以根据用户输入动态触发不同的意图。
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。