简体   繁体   English

Node.js Wit.ai集成

[英]Node.js Wit.ai integration

I am learning wit.ai and going through the tutorial ( https://wit.ai/docs/quickstart ). 我正在学习wit.ai并完成本教程( https://wit.ai/docs/quickstart )。 Everything else went well till step 6, where it asked me to clone the node.js client and install npm. 一切顺利,直到第6步,它要求我克隆node.js客户端并安装npm。 Usually, I create a separate node.js project then npm intall whatever-the-module-is then use it. 通常,我创建一个单独的node.js项目,然后在所有模块中npm intall都使用它。

I am confused on how to use node-wit. 我对如何使用node-wit感到困惑。 I want to create my own node.js server which will be called by my bot to implement the business logic. 我想创建自己的node.js服务器,该服务器将由我的机器人调用该服务器以实现业务逻辑。 Here are few questions I need help with: 这是我需要帮助的几个问题:

  1. Can I just create a basic node.js project, install node-wit and use it? 我可以只创建一个基本的node.js项目,安装node-wit并使用它吗?

  2. If I deploy my node project on heroku, where do I provide the endpoint for wit.ai to call? 如果将节点项目部署在heroku上,该在哪里提供wit.ai调用的端点? The tutorial does not mention anything about it. 本教程未提及任何内容。

  3. Can I perform the business logic without using Promise or any code they have given in the node-wit tutorial? 是否可以在不使用Promise或他们在node-wit教程中提供的任何代码的情况下执行业务逻辑?

Overall I am just confused on how the node-wit code is working. 总体而言,我只是对节点智能代码的工作方式感到困惑。

Thanks. 谢谢。

1) Yes you can. 1)是的,可以。 Simply run npm install --save node-wit , check out the github for more infos https://github.com/wit-ai/node-wit 只需运行npm install --save node-wit ,查看github以获得更多信息https://github.com/wit-ai/node-wit

2) Endpoints url are set within the module. 2)端点URL在模块内设置。 Check the lib/config.js file. 检查lib / config.js文件。 You just have to specify your API key to communicate with Wit. 您只需要指定您的API密钥即可与Wit通信。

3) The SDK uses only promises, so you have to use them too. 3)SDK仅使用承诺,因此您也必须使用它们。 Two solutions here : i) master this concept, my guess is that's it's worth it since promises are very handfull ii) code your own API calls, this is not difficult (check the HTTP API doc) 这里有两个解决方案:i)掌握这个概念,我的猜测是值得的,因为promise非常简单; ii)编写自己的API调用,这并不困难(请查看HTTP API文档)

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

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