1.2.4 • Published 2 years ago

robo-js-sdk v1.2.4

Weekly downloads
3
License
ISC
Repository
-
Last release
2 years ago

robo-js-sdk

Welcome to our robo-js-sdk tutorial.

What is this SDK for?

This is a Javascript SDK to access the ROBO.AI API.

Import into your project

Import it as a module

robo-js-sdk is available on npm. To install it just execute:

$ npm install robo-js-sdk

Then you can import the RoboAi SDK class into your code:

import RoboAi from "robo-js-sdk";

In the browser

You can also use it directly within the browser, for example using unpkg:

<script src="//unpkg.com/robo-js-sdk@latest/dist/roboAi.js"></script>

Usage

After importing the RoboAi class you can initialize a new instance:

const config = {
  url: "<BACKEND_URL>",
  apikey:"<API_KEY>", // Use your ROBO.AI account to generate an API key 
  basicAuth: {
    user: "<BASIC_AUTH_USERNAME>",
    psw: "<BASIC_AUTH_PASSWORD>"
  }
};

const roboAi = new RoboAi(config);

Available methods

To list assistants:

roboAi.getAssistants()

Using this method will return an array of assistants like this:

[
  {
    "uuid": "bot-uuid",
    "name": "bot-name",
    "description": "I am a bot",
    "displayName": "Helena",
    "created": "2020-03-25T11:52:42.000+0000",
    "updated": "2021-02-02T15:58:59.000+0000",
    "status": "ENABLED/DISABLED"
  }
]

To get a specific assistant;

const assistantUuid = "bot-uuid"
roboAi.getAssistant(assistantUuid)

Using this method will return a specific assistant like this:

{
  "uuid": "bot-uuid",
  "name": "bot-name",
  "description": "I am a bot",
  "displayName": "Helena",
  "created": "2020-03-25T11:52:42.000+0000",
  "updated": "2021-02-02T15:58:59.000+0000",
  "status": "ENABLED/DISABLED"
}

To start a dialogue with a specific assistant;

const assistantUuid = "bot-uuid"
roboAi.startDialogue(assistantUuid)

Using this method will return a response like this:

{
  "message": "text",
  "dialogueUuid": "0be3b300-54ba-4220-9059-e2a86ffe2208",
  "answers": [
    {
      "type": "ssml",
      "ssml": "<speak>Hi, how can I help?</speak>"
    },
    {
      "type": "text",
      "text": "Hi, how can I help?"
    }
  ],
  "assistantUuid": "bot-uuid"
}

To send a message within a dialogue;

const dialogueUuid = "0be3b300-54ba-4220-9059-e2a86ffe2208"
const messageRequest = {
  message: 'text',
};
roboAi.sendMessage(dialogueUuid, messageRequest) 

Using this method will return a response like this:

{
  "message": "text",
  "dialogueUuid": "0be3b300-54ba-4220-9059-e2a86ffe2208",
  "answers": [
    {
      "type": "ssml",
      "ssml": "<speak>I am a bot</speak>",
      "audio": "bsbygydhbddjddu...",
      "audioContentType": "audio/mp3"
    },
    {
      "type": "text",
      "text": "I am a bot"
    }
  ],
  "assistantUuid": "martin---status-tracking-es"
}

To send an event within a dialogue;

const dialogueUuid = "0be3b300-54ba-4220-9059-e2a86ffe2208"
const eventRequest = {
  type: 'command',
  name: 'test',
  params: [
    {
      key: 'key',
      value: 'value',
    },
  ],
};
roboAi.sendEvent(dialogueUuid, eventRequest)

Using this method will return a response like this:

 {
  "message": "{\"type\":\"command\",\"name\":\"test\",\"params\":[{\"key\":\"key\",\"value\":\"value\"}]}",
  "dialogueUuid": "0be3b300-54ba-4220-9059-e2a86ffe2208",
  "answers": [
    {
      "type": "ssml",
      "ssml": "<speak>This is an answer.</speak>"
    },
    {
      "type": "text",
      "text": "This is an answer."
    }
  ],
  "assistantUuid": "martin---status-tracking-es"
}

To send feedback;

const dialogueUuid = "0be3b300-54ba-4220-9059-e2d86ffe2208"
const feedback = {
  questions: ['Test question 1?', 'Test question 2?', 'Test question 3?'],
  expectedAnswer: 'expected answer',
  trustedSourceUrl: 'http://trustedurl.example',
};
roboAi.feedback(dialogueUuid, feedback)

Using this method will return a response like this:

 {
  "dialogueUuid": "0be3b300-54ba-4220-9059-e2d86ffe2208",
  "answers": [
    {
      "type": "ssml",
      "ssml": "<speak>I am a bot.</speak>"
    },
    {
      "type": "text",
      "text": "I am a bot"
    }
  ]
}

To send Conversation Rating;

const dialogueUuid = "0be3b300-54ba-4220-9059-e2d86ffe2208"
const rating = {
  sentiment: 'GOOD', // possible values are: 'GOOD', 'BAD', 'NEUTRAL',
  comments: 'I love this bot'
};
roboAi.rating(dialogueUuid, rating)

Using this method will return a string response like this:

  "sucess"
1.2.0

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.15

3 years ago

1.1.14

3 years ago

1.1.13

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.1

4 years ago

1.1.2

4 years ago

1.1.0

4 years ago

1.0.44

5 years ago

1.0.43

5 years ago

1.0.42

5 years ago

1.0.41

5 years ago

1.0.40

5 years ago

1.0.39

5 years ago

1.0.38

5 years ago

1.0.37

5 years ago

1.0.36

5 years ago

1.0.35

5 years ago

1.0.34

5 years ago

1.0.33

5 years ago

1.0.32

5 years ago

1.0.31

5 years ago

1.0.3

5 years ago

1.0.0

5 years ago