Skip to content
Javascript promise-based wrapper around the Rainbird API
JavaScript
Branch: master
Clone or download
dependabot and tom-sherman Bump eslint-utils from 1.3.1 to 1.4.2 (#8)
Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.3.1 to 1.4.2.
- [Release notes](https://github.com/mysticatea/eslint-utils/releases)
- [Commits](mysticatea/eslint-utils@v1.3.1...v1.4.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: null <49699333+dependabot[bot]@users.noreply.github.com>
Latest commit 627199c Aug 27, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
src
test
.gitignore
.travis.yml
LICENSE
README.md
example.js
package-lock.json
package.json

README.md

rainbird-api-js Build Status

A promise-based wrapper around the Rainbird API

Install

Requires Node v8.11.0 or later.

npm install rainbird-api --save

Usage

const rb = require('rainbird-api')

// Start a new session
const session = new rb.Session(apiKey)
await session.start(knowledgeMapId)

await session.query({
  subject: 'John',
  relationship: 'speaks'
})
// > { question: { prompt: 'Where does John live?', ... } }

// Inject facts
await session.inject({
  subject: 'Sam',
  relationship: 'lives in',
  object: 'France'
})

// Respond with a fact
const { facts } = await session.respond({
  subject: 'John',
  relationship: 'lives in',
  object: 'England'
})

// Get an evidence tree object by calling audit on the answer.
await facts[0].audit()

Context

Context is supported but supplying a contextId option when creating a new Session eg.

const session = new rb.Session({
  apiKey: API_KEY,
  contextId: '123'
})

Notes

Session.response and Session.query can return either questions or facts (answers)

Development

Clone and install dependencies

git clone https://github.com/tom-sherman/rainbird-api-js
cd rainbird-api-js
npm install

You must set the following environment variables to be able to run tests:

  • RB_API_KEY - A valid Rainbird API key.
  • RB_HELLOWORLD_KMID - A "Hello World" knowledge map.

These can be placed in a .env file for convenience.

Further reading

You can’t perform that action at this time.