initai-node

0.0.14 • Public • Published

Init.ai Node.js SDK

A Node.js utility to manage conversation logic, event invocations, and compose replies for your Init.ai application.

Requirements

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 = require('initai-node')

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.create(data)

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 = new InitClient.create(data)
const done = () => client.sendResult().then(() => console.log('Done!'))
 
client.addResponse('provide_gametime', { team: 'Chicago Cubs' })
done()

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

Readme

Keywords

none

Package Sidebar

Install

npm i initai-node

Weekly Downloads

0

Version

0.0.14

License

UNLICENSED

Last publish

Collaborators

  • init.ai