如何在没有Cloud Functions的情况下将请求从iOS(Swift)发送到Dialogflow V2 API? [英] How to send request from iOS (Swift) to Dialogflow V2 API without Cloud Functions?

查看:61
本文介绍了如何在没有Cloud Functions的情况下将请求从iOS(Swift)发送到Dialogflow V2 API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以(以及如何)直接调用Dialogflow V2 API以从iOS应用程序(Swift)进行意图检测,或者我是否需要按照此处的建议使用Cloud Functions 将企业版v2的对话框流集成到ios和andriod应用程序中

Is it possible (and how) to call Dialogflow V2 API directly for intent detection from iOS app (Swift) or do I need to use Cloud Functions as suggested here Dialogflow integration of enterprise edition v2 into the ios and andriod app ?

我在Dialogflow上有一些经验,但是我所有的集成工作都是由FB Messenger / Web演示完成的,所以我在iOS情况下完全迷失了,在GCP / DF文档中找不到清晰的解释。

I have some experience in Dialogflow but all my integrations were done by FB Messenger / Web demo so I am totally lost in iOS case and I cannot find clear explanation in GCP / DF documentation.

推荐答案

虽然是可能,但这不是一个好主意。

While it is possible, it is not a good idea.

理论上,您可以调用对话框流直接使用REST接口从您的应用程序中检测意图API。

In theory, you can call the Dialogflow Detect Intent API directly from your application using a REST interface.

问题是,为此,您需要包括身份验证。此身份验证基于服务帐户和该帐户的私钥。

The problem is that, as part of this, you need to include authentication. This authentication is based on a service account and the private key for that account.

因此,要向服务发送请求,您需要在其中包含私钥您的应用。您可能会猜到-这有点不安全。这就是为什么您链接到的SO问题建议使用网络服务(不一定在Cloud Functions上,它可以在任何地方)作为中介。您可以将私钥放在服务中,在此可以更好地保护私钥,并在需要时使用一些不太安全的方法在应用程序和服务之间进行通信。

So in order to send a request to your service, you need to include the private key in your app. As you might guess - this is somewhat insecure. Which is why the SO question you link to suggests using a web service (it doesn't have to be on Cloud Functions - it can be anywhere) as the intermediary. You can put the private key in the service, where it can be more protected, and use some less secure method to communicate between your app and the service if you feel its necessary.

这篇关于如何在没有Cloud Functions的情况下将请求从iOS(Swift)发送到Dialogflow V2 API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆