Init.ai Node.js SDK
A Node.js utility to manage conversation logic, event invocations, and compose replies for your Init.ai application.
Requirements
- An Init.ai account and project
- A working Logic Invocation webhook
- Node.js version 4.3.2 or later (https://nodejs.org/en/download/)
Install
npm i -S initai-node
Usage
For a detailed reference, visit: https://docs.init.ai/docs/node-js-sdk
Before starting, ensure you have a webhook configured to handle a logic invocation.
Include the library in your project
const InitClient =
Instantiate a client instance
The payload sent to your webhook for the LogicInvocation
event (See webhooks docs) contains an Object for you to provide to your client instance.
data
: Object – The logic invocation data received from your webhook. (Docs)
const client = InitClient
Sending the logic result
Prior to version 0.0.14,
it was required that you manually send a logic invocation result to our API. With version 0.0.14
, a new method sendResult
was added which handles this call for you.
const client = dataconst done = client client
Development
Testing
$ npm t
To run continuous tests:
$ npm run test:watch
Docs
To view the JSDoc output locally, run:
$ npm run jsdoc
then visit http://localhost:3044