简体   繁体   English

如何使用Webhook将数据库集成到api.ai聊天机器人

[英]How to integrate a database to api.ai chat-bot using a webhook

I'm developing a chat-bot using api.ai for NLP and i'm stucked where i need to query some data from a database. 我正在使用api.ai开发用于NLP的聊天机器人,并且卡在需要从数据库查询一些数据的地方。 And also i need to do some processing of those data. 而且我还需要对这些数据进行一些处理。 I'm not much clear how can I do this using the webhook. 我不太清楚如何使用webhook做到这一点。 Any thoughts and tips would be really appreciated. 任何想法和技巧将不胜感激。

You might want to check out API.AI's getting started guide, the last part of which involves the basics of adding fulfillment to your agent which pulls from this getting started sample 您可能想要查看API.AI的入门指南,其中的最后一部分涉及从代理 入门示例中获取 知识的基础知识,以向您的代理添加实现功能

We use Cloud Functions for Firebase in the sample but you can't call non-Google APIs or URLs without setting up billing. 我们在示例中将Cloud Functions用于Firebase,但是如果不设置结算方式,就无法调用非Google API或URL。 You can also use any other hosting providers (Google's AppEngine, Compute Engine, Amazon's Lambda, EC2, Heroku, Azure, etc.) for fulfilling API.AI agents, as long as you have a server that can respond to a HTTPS request, it'll work with API.AI's webhook fulfillment. 您还可以使用任何其他托管服务提供商(Google的AppEngine,Compute Engine,Amazon的Lambda,EC2,Heroku,Azure等)来实现API.AI代理,只要您拥有可以响应HTTPS请求的服务器,将与API.AI的webhook实现配合使用。 To get started you can even use your local machine and tools like ngrok to tunnel the connection from a HTTPS URL to your local development machine: https://ngrok.com/ . 首先,您甚至可以使用本地计算机和ngrok之类的工具来将连接从HTTPS URL隧道传输到本地开发计算机: https ://ngrok.com/。 If your just starting out I'd recommend doing whatever your most comfortable with. 如果您刚刚起步,我建议您做最舒适的事情。

Am currently using Node-RED to process the data received through the webhook. 当前正在使用Node-RED处理通过Webhook接收的数据。 The webhook receives the data in JSON and if you've setup your intents and entities correctly, you'll get data that you can act on. Webhook会以JSON格式接收数据,如果您正确设置了意图和实体,您将获得可以执行操作的数据。

This can be achieved as a stand-alone nodeJS app that you host somewhere, like Heroku or OpenShift. 这可以通过在诸如Heroku或OpenShift之类的地方托管的独立nodeJS应用程序来实现。 But important point is that you need a server running a program somewhere to process the data that api.ai sends. 但重要的一点是,您需要一台在某处运行程序的服务器来处理api.ai发送的数据。

Am using firebase as my database and is integrated into my Node-RED setup and now I can do sophisticated queries like “how much did I walk last Wednesday” 我正在使用firebase作为数据库并将其集成到Node-RED设置中,现在我可以进行复杂的查询,例如“上周三我走了多少路”

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

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