beevelop / rasa-client

Simple Node.js wrapper around the Rasa core HTTP server

Home Page:https://beevelop.github.io/rasa-client/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Travis npm Release xo-code-style Status Badges Beevelop

Rasa Core HTTP Client for Node.js 🐦

⚠️ Still WIP: API is unstable and might change. Consider this a technical preview.

Simple Node.js wrapper around the Rasa core HTTP server.

Installation

Install via npm:

npm install --save rasa-client

Usage

const RasaClient = require('rasa-client')

// first param is the endpoint without trailing slash
// optionally the second parameter can be an authentication token
const rc = new RasaClient('http://localhost:5005')
rc.parse('Hello world').then((res) => console.log)
rc.getVersion().then((res) => console.log)

Examples

// Full example with the remotebot example (from the official Rasa core repo)

const SENDER_ID = 'anon'
// Greet the bot
const msg1 = 'hello'
rc.parse(msg1, SENDER_ID).then(reply => {
  return rc.continue({
    executed_action: 'greet'
  }, SENDER_ID)
}).then(cont1 => {
  // next_action is action_listen in this case
  // therefore we can initiate a new parse request

  // Send venues request
  const msg2 = 'Whats the next event'
  return rc.parse(msg2, SENDER_ID)
}).then(reply => {
  return rc.continue({
    executed_action: 'search_concerts',
    events: [{ event: 'slot', name: 'venues', value: [
      {name: "Big Arena", reviews: 4.5},
      {name: "Small Arena", reviews: 4.2}
    ]}]
  }, SENDER_ID)
}).then(cont2 => {
  // you get the point...
})

About

Simple Node.js wrapper around the Rasa core HTTP server

https://beevelop.github.io/rasa-client/

License:MIT License


Languages

Language:JavaScript 98.2%Language:Shell 1.8%