简体   繁体   English

哪个更好用于Google智能助理? Actions SDK或JSON请求响应

[英]Which is better to use for Google Assistant? Actions SDK or JSON request response

I have built multiple actions on Google Assistant using the JSON request and response V2 but I have heard that using Actions SDK for building actions specifically for Google Assistant should be preferred. 我已使用JSON请求和响应V2在Google智能助理上构建了多个操作,但我听说使用Actions SDK专门为Google智能助理构建操作应该是首选。 I am confused whether to use Actions SDK or JSON request response? 我很困惑是否使用Actions SDK或JSON请求响应?

For example - On this link , for every sample code there are two tabs, Node.js using Actions SDK and JSON using the JSON request response. 例如 - 在此链接上 ,对于每个示例代码,都有两个选项卡,Node.js使用Actions SDK,JSON使用JSON请求响应。

Which one should be preferred and in which scenarios? 应该首选哪一个以及哪种情况?

Thanks! 谢谢!

Let's first look at what those tabs mean, and then discuss what your best approach should be. 让我们首先看一下这些标签的含义,然后讨论你最好的方法应该是什么。

node.js vs JSON tabs node.js vs JSON选项卡

The "node.js" tab shows what the code looks like using the actions-on-google library. “node.js”选项卡显示使用actions-on-google库的代码。 For the most part, this library uses the same code if you're using either the Action SDK or using Dialogflow to implement. 在大多数情况下,如果您使用Action SDK或使用Dialogflow来实现,则此库使用相同的代码。 Where there are differences, the documentation does note how you have to handle them - this is particularly true when it comes to how you have to handle responses. 如果存在差异,文档会记录您必须如何处理它们 - 当涉及到如何处理响应时尤其如此。

The "JSON" tab shows what the JSON would look like if you are not using the actions-on-google library and need to send JSON yourself. “JSON”选项卡显示如果您没有使用Google上的操作库并且需要自己发送JSON,JSON会是什么样子。 You might do this because you're using a language besides node.js, or you just want to know what the underlying protocol looks like. 您可能这样做是因为您使用的是除node.js之外的语言,或者您只是想知道底层协议的外观。

The catch is that the JSON illustrated here is what would be used by the Action on Google JSON protocol . 问题在于,此处所示的JSON是Action on Google JSON协议所使用的内容 If you're using Dialogflow, then this JSON would be wrapped inside the payload.google field and there are a couple of other differences documented . 如果您使用Dialogflow,那么这个JSON将里面包裹payload.google领域,有一对夫妇的其他差异记录 So when generating JSON for a Dialogflow response, you should use this as a guide, but need to be aware of how it might differ. 因此,在为Dialogflow响应生成JSON时,您应该将其用作指南,但需要注意它可能有何不同。

What should you use? 你应该用什么?

What you use depends on what your needs are and what your goals are for developing. 您使用的内容取决于您的需求以及您的目标是什么。

If you are trying to develop something you intend to release, or might do so someday, and you are new to voice or bot interfaces, then you'll probably want to use Dialogflow - no matter what other choices you may make. 如果你正在尝试开发你想要发布的东西,或者有一天可能会这样做,并且你是语音或僵尸界面的新手,那么你可能想要使用Dialogflow - 无论你做出什么其他选择。

If you have your own Natural Language Processing (NLP) system, then you will want to use the Action SDK instead of Dialogflow. 如果您有自己的自然语言处理(NLP)系统,那么您将需要使用Action SDK而不是Dialogflow。 How you handle it (using the actions-on-google library or using JSON) will depend on how you need to integrate with that NLP. 你如何处理它(使用动作在谷歌库或使用JSON)将取决于你需要如何与该NLP集成。

If you're familiar with node.js, or want to learn it, then using the actions-on-google library is a good choice and that first tab will help you. 如果您熟悉node.js或想要学习它,那么使用actions-on-google库是一个不错的选择,第一个选项卡将对您有所帮助。 (There are other choices. Dialogflow also has a dialogflow-fulfillment library, which is good if you want to be able to support the bot platforms it supports as well. The multivocal library has a more configuration-driven template approach to building a conversational backend that was designed to work with the Assistant and Dialogflow. Both of these illustrate how to do the same things that Google's documentation does.) (还有其他选择.Dialogflow还有一个对话框实现库,如果你想能够支持它支持的机器人平台,这是很好的。 多用途库有一个更加配置驱动的模板方法来构建会话后端旨在与Assistant和Dialogflow配合使用。这两个都说明了如何执行与Google文档相同的操作。)

If you would rather use another language, you'll need to reference the JSON documentation because there are few complete libraries for these platforms. 如果您更愿意使用其他语言,则需要引用JSON文档,因为这些平台的完整库很少。 Your best bet would be to use Dialogflow with JSON. 您最好的选择是使用带有JSON的Dialogflow。 Dialogflow has some example JSON for how to apply the Google documentation you cite to their fulfillment protocol . Dialogflow有一些示例JSON,用于如何应用您引用其执行协议的Google文档。

Summary 摘要

  • You should probably use Dialogflow. 您应该使用Dialogflow。
  • If you can, use actions-on-google or another library. 如果可以,请使用google上的操作或其他库。
  • If you have a need to use another language or want to use the JSON, be aware of the possible differences. 如果您需要使用其他语言或想要使用JSON,请注意可能存在的差异。

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

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