简体   繁体   English

对话结束后如何使用Google Assistant回应用户?

[英]how to respond to user using google assistant after the conversation is ended?

I am making a google action.I have one scenario where calculation requires some time in cloud fulfillment but i don't want to keep user waiting for answer. 我正在做一个谷歌动作。我有一种情况,计算需要一些时间才能实现云,但我不想让用户等待答案。 I want to respond to user whenever my answer is ready even when conversation with user is ended i want to send my answer in notification or something like that. 我想在答案准备好后就回复用户,即使与用户的对话结束时,我也想以通知或类似方式发送答案。

I just found this on google actions documents. 我刚刚在Google Actions文档中找到了这个。 https://developers.google.com/actions/assistant/updates https://developers.google.com/actions/assistant/updates

Is this possible in google actions and how? Google动作有可能吗?如何?

What you mean here is notifications . 您的意思是通知 You can use it but please pay attention to the warning at the top of the link you provided: "Updates and notifications are currently in Developer Preview. You can build apps using the features described in this article, but you can't currently publish them". 您可以使用它,但请注意提供的链接顶部的警告:“开发人员预览中当前有更新和通知。您可以使用本文中介绍的功能来构建应用程序,但目前无法发布它们”。

As for the steps to crated a daily notification: 关于创建每日通知的步骤:

  1. Navigate to your actions.intent.CONFIGURE_UPDATES intent. 导航到您的actions.intent.CONFIGURE_UPDATES目的。
  2. Under Responses, go to the Google Assistant tab, click Add Message Content, and select Custom Payload. 在“响应”下,转到“ Google助手”标签,单击“添加邮件内容”,然后选择“自定义有效载荷”。

    1. In the "Custom Payload" box, add the following code to call the AskToRegisterDailyUpdate helper. 在“自定义有效负载”框中,添加以下代码以调用AskToRegisterDailyUpdate帮助器。 Swap INTENT_NAME to the intent that you want to be invoked when the user interacts with your notification. 当用户与您的通知交互时,将INTENT_NAME交换为您要调用的意图。

    { {

     "google": { "system_intent": { "intent": "actions.intent.REGISTER_UPDATE", "data": {"@type": "type.googleapis.com/google.actions.v2.RegisterUpdateValueSpec", "intent": "INTENT_NAME", "triggerContext": { "timeContext": { "frequency": "DAILY" } } } } 

    } } }}

    1. If using a webhook, you can call this API directly via the client library: 如果使用Webhook,则可以直接通过客户端库调用此API:

       appMap.set('setup_update', function(app) { app.askToRegisterDailyUpdate('INTENT_NAME'); }) 

      }) })

    2. Add one more intent called "finish_update_setup" and enter actions_intent_REGISTER_UPDATE as its Event. 再添加一个名为“ finish_update_setup”的意图,并输入actions_intent_REGISTER_UPDATE作为其事件。

    3. Set the intent's Action to "finish_update_setup" as well. 还将意图的操作设置为“ finish_update_setup”。

    4. In your webhook, open index.js and add the following. 在您的webhook中,打开index.js并添加以下内容。 Replace Ok, I'll start giving you daily updates and Ok, I won't give you daily updates. 替换好吧,我将开始为您提供每日更新,好吧,我将不为您提供每日更新。 with whatever response you want to give the user: 您想要给用户的任何响应:

       appMap.set('finish_update_setup', function(app)) { if (app.isUpdateRegistered()) { app.tell("Ok, I'll start giving you daily updates."); } else { app.tell("Ok, I won't give you daily updates."); } } 
    5. Deploy the webhook to Firebase Functions and enable webhook fulfillment in Dialogflow. 将Webhook部署到Firebase Functions,并在Dialogflow中启用Webhook实现。

If you want to see how to create a simple notification (not daily one) - please check this doc on push notifications . 如果您想了解如何创建简单的通知(而不是每日通知),请查看此文档有关推送通知

If you don't have an immediate reply to send but expect one soon-ish what you do is return a "promise". 如果您没有立即发送的答复,但希望您很快就能完成,则返回“承诺”。 When you are in a position to reply, "fulfilling" the promise causes your reply to be delivered. 当您有能力答复时,“履行”诺言会使您的答复得以交付。 I don't know what the actual timeout is but in my case I'm pretty sure at least a few second delay is allowed. 我不知道实际的超时时间是多少,但就我而言,我很确定至少可以延迟几秒钟。

As for the updates or notifications, the API is there but the docs say you can't deploy an Action to production using them. 至于更新或通知,API在那里,但是文档说您不能使用它们将Action部署到生产中。 There is a slightly cryptic comment to "contact support" if you need them. 如果需要,“联系支持”中会有一个含糊的注释。

One of these days I might try. 这些日子之一,我可能会尝试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM