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

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

问题描述

是否可以(以及如何)直接调用 Dialogflow V2 API 以从 iOS 应用程序(Swift)进行意图检测,或者我是否需要按照此处的建议使用 Cloud Functions Dialogflow企业版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.

理论上,您可以调用 Dialogflow Detect Intent API 直接从您的应用程序使用 REST 接口.

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 问题建议使用 Web 服务(它不必在 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天全站免登陆