简体   繁体   English

通过API返回对Google智能助理的回复

[英]Return response to Google Assistant via API

I have a Actions on Google project that uses api.ai for its actions. 我有一个使用api.ai进行操作的Google项目动作。 This is working well and I can see request/responses appear on the google assistant interface (On mobiles and simulator) 这很好用,我可以在google助手界面上看到请求/回复(在手机和模拟器上)

One of my usecases for api.ai needs to broken into 2 parts, in that we have to inform the user that the processing has started and then inform them again once its completed (without them reprompting for the output). 我对api.ai的一个用例需要分为两部分,因为我们必须通知用户处理已经开始,然后在完成后再次通知它们(没有它们重新输出输出)。

Im trying for a way to inform the user who is using the Google assistant when the processing is completed, but have failed so far. 我试图在处理完成时告知正在使用Google助手的用户,但到目前为止失败了。 Something like this 像这样的东西

User: I would like to see if my loan request is approved 用户:我想看看我的贷款申请是否获得批准

Google Assistant: Hold on, let me check and let u know . Google智能助理:等一下,让我检查并告诉你。

.... (Makes a webservice call to the backend asynchronously) ....(异步调用后端的web服务)

.... After few seconds ... ......几秒钟后......

.... Postback to google assistant from the webservice ....从网络服务回复谷歌助理

Google Assistant: Thanks for holding, your request is approved. Google智能助理:感谢您的支持,您的申请已获批准。

Im not sure how to do the "postback to google assistant" call. 我不知道如何做“回复谷歌助理”电话。 I have tried to get the SessionId from the Api.AI call and then use that to make a event request , but that doesnt seem to send the response to the assistant. 我试图从Api.AI调用中获取SessionId,然后使用它来发出事件请求,但似乎并没有将响应发送给助手。 Google Assistant seems to be using the formats defined in https://developers.google.com/actions/reference/rest/Shared.Types/AppRequest , but Im unsure how to get the ConversationToken and use that for sending the response back to the user. Google智能助理似乎使用了https://developers.google.com/actions/reference/rest/Shared.Types/AppRequest中定义的格式,但我不确定如何获取ConversationToken并将其用于将响应发送回用户。

Short answer: you can't do that. 简短的回答:你做不到。

Slightly longer answer: At least right now, there is no good way to send a notification. 稍微长一点的回答:至少现在,没有好的方法来发送通知。 Your Action can only respond to a specific statement from the user. 您的操作只能响应用户的特定声明。 You can say something like "ask again in a minute and I should have a result for you", but that isn't a great experience. 可以说“在一分钟内再问一次,我应该为你找到一个结果”,但这不是一个很棒的经历。 At Google I/O 2017, they announced that notifications would be coming to the Google Home at some point... but gave neither a time frame nor any information about an API. 在Google I / O 2017上,他们宣布将在某个时候向Google Home发送通知......但既没有提供时间范围也没有提供有关API的任何信息。

Long, but probably still unsatisfying answer: You can look into Transactions which let them initiate purchase or request of some sort and then "check out". 很长,但可能仍然不满意的答案:您可以查看交易 ,让他们发起购买或某种要求,然后“结账”。 Once they have checked out, you would confirm that a transaction is being processed with an OrderUpdates and then can send updates with the status of the "order". 一旦签出,您将确认正在使用OrderUpdates处理事务,然后可以发送具有“订单”状态的更新。 These status updates can turn into notifications or user's can query the state of the order at any time. 这些状态更新可以变成通知,或者用户可以随时查询订单状态。 Transactions don't require payment, so this may work depending on your needs. 交易要求付款,所以这可能取决于你的工作需要。

However, there are a few things to note. 但是,有一些事情需要注意。 This is still in developer preview, so things may change in the future. 这仍然在开发人员预览中,因此将来可能会发生变化。 It also doesn't work on all surfaces where the Assistant runs, so while it does work on Assistant on phones, it does not work on the Google Home right now. 它也不会在助理运行的所有表面上工作,因此,尽管它确实对助理工作在手机上,它并没有在谷歌主页的工作现在。

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

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