[英]I want my google assistant application to talk to my webserver first and then dialogflow
I want my Google Assistant application to talk to my webserver first and then Dialogflow. 我希望我的Google Assistant应用程序先与我的网络服务器对话,然后再与Dialogflow对话。 The way DialogFlow is documented, the Assistant talks to it first, and then it is passed to my webhook.
记录DialogFlow的方式,助手首先与之对话,然后将其传递到我的webhook。 I want to do it the other way.
我想换一种方式。
To have the Google Assistant talk directly to your server (without Dialogflow in between) you need to use the Actions SDK . 要使Google Assistant直接与您的服务器对话(两者之间没有Dialogflow),您需要使用Actions SDK 。 You'll create an actions.json file which defines triggering information and the URL for a webhook.
您将创建一个actions.json文件,该文件定义触发信息和Webhook的URL。 (You can't get rid of the webhook - just change how it is called.) Your webhook will be called with JSON that has a different format from Dialogflow's JSON format, or you can use the node.js library which has a similar interface to the Dialogflow version.
(您无法摆脱Webhook,只需更改其调用方式即可。)将使用与Dialogflow JSON格式不同格式的JSON来调用Webhook,或者可以使用具有类似接口的node.js库到Dialogflow版本。
Your webhook can, then, call Dialogflow using the /query endpoint (for Dialogflow V1 API) or the detectIntent message (for the Dialogflow V2 API). 然后,您的Webhook可以使用/ query端点 (对于Dialogflow V1 API)或detectIntent消息 (对于Dialogflow V2 API)调用Dialogflow。 You can send it the text from the user or an event indicating the user's action (or, really, anything you want) along with parameters and Contexts that you wish.
您可以向它发送来自用户的文本或一个事件,该事件指示用户的操作(或者,实际上,您想要执行的任何操作)以及所需的参数和上下文。 Dialogflow will send a reply, either from it's reply section or by sending it to another fulfilment webhook - whatever you choose.
Dialogflow将从其答复部分发送答复,也可以将其发送到另一个实现Webhook(无论您选择什么)。
Your server will get this reply, along with any Contexts and parameters that are set. 您的服务器将收到此回复以及设置的所有上下文和参数。 It sounds like you'll send the reply to the user, probably without further processing, although you can do whatever you want.
听起来您可能会将回复发送给用户,尽管您可以做任何您想做的事情,但可能无需进一步处理。 You may want to store the context information in the conversation token , the user storage object , or in some other data store your server wishes to use.
您可能希望将上下文信息存储在会话令牌 , 用户存储对象或服务器希望使用的某些其他数据存储中。
There are some samples for using the Actions SDK although none of them illustrate calling Dialogflow from the webhook. 尽管没有一个示例说明如何从Webhook调用Dialogflow,但仍有一些示例可以使用Actions SDK 。 (It is not a very common pattern - most use cases work better the other way.) The samples for Dialogflow are mostly for webhooks, although the "Agent to human handoff" does illustrate sending to Dialogflow from your code.
(这不是一个非常常见的模式-大多数用例都可以用其他方式更好地工作。) Dialogflow的示例主要是针对Webhooks的,尽管“从人到人的代理”确实说明了从代码发送至Dialogflow。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.