【问题标题】:Dialogflow with fulfillment: get answer opening an URL httpDialogflow withfulfillment: get answer opening an URL http
【发布时间】:2018-10-16 10:01:37
【问题描述】:

找了半天也没找到合适的答案。

我目前正在 Dialogflow 中构建代理。该代理将集成在网页中(因此它既不是 Facebook Messenger,也不是 Google Assistant 的一部分)。该代理应该根据用户正在寻找的内容将用户重定向到网站的特定页面。

我想知道我应该在我的内联编辑器中输入什么类型的代码以获得一个意图答案,该答案将自动执行在浏览器的新窗口/选项卡中打开 URL 的操作。

应该是这样的:

User: "Hi, I would like the list of red bikes that are available in your shop"
Bot reply: "OK, here you have the list of all the red bikes we have in stock".
-> Then the bot open the page with the red bikes in a new tab/window.

我认为这部分代码应该插入到下面的代码块中,但是我是初学者,所以我不确定我的做法是否正确:

function userNeed(agent) {
    // code that would open the URL
}
intentMap.set('User Need', userNeed);

如果这样的操作不可用,有没有办法将 URL 作为可点击的超链接包含在机器人答案中?

希望它足够清楚。 非常感谢。

【问题讨论】:

  • 你找到解决办法了吗,如果有请发帖

标签: javascript url dialogflow-es fulfillment


【解决方案1】:

是的,这就是代码所在的位置。在新窗口中打开的代码是:

window.open("https://www.website.com");

您也可以在用户使用setTimeout(). 阅读机器人消息后延迟执行此操作

setTimeout(function(){ window.open("https://www.website.com"); }, 3000);

很遗憾,我认为 Dialogflow 不支持此功能,但请尝试一下。

要发布可点击的超链接,只需在响应字符串中添加 URL,然后在 userNeed 函数中输入:

agent.add("OK, here you have the list of all the red bikes we have in stock. Here's a link: https://www.website.com");

了解如何在内联编辑器中编写代码的一个良好开端是查看示例,例如temperature trivia 示例。对于不是 Google 助理的平台,还有一个 getting started guide

【讨论】:

    猜你喜欢
    • 2016-11-13
    • 2019-05-24
    • 1970-01-01
    • 2017-08-26
    • 2013-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-02
    相关资源
    最近更新 更多