Node.js Wit.ai integration

661 views Asked by At

I am learning wit.ai and going through the tutorial (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. Usually, I create a separate node.js project then npm intall whatever-the-module-is then use it.

I am confused on how to use node-wit. I want to create my own node.js server which will be called by my bot to implement the business logic. Here are few questions I need help with:

  1. Can I just create a basic node.js project, install node-wit and use it?

  2. If I deploy my node project on heroku, where do I provide the endpoint for wit.ai to call? 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?

Overall I am just confused on how the node-wit code is working.

Thanks.

1

There are 1 answers

1
Nitsuja On BEST ANSWER

1) Yes you can. Simply run npm install --save node-wit, check out the github for more infos https://github.com/wit-ai/node-wit

2) Endpoints url are set within the module. Check the lib/config.js file. You just have to specify your API key to communicate with Wit.

3) The SDK uses only promises, so you have to use them too. 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)