$ cnpm install robo-js-sdk
Welcome to our robo-js-sdk tutorial.
This is a Javascript SDK to for the ROBO.AI API.
robo-js-sdk
is available on npm. To install it try:
$ npm install robo-js-sdk
You can also use it within the browser, install via npm and use the roboAi-sdk.js
file found within the download. For example:
<script src="./node_modules/robo-js-sdk/dist/roboAi.js"></script>
Import the library in your code, and then start a new roboAi to get new communication:
const config = {
url: "<BACKEND_URL>",
apikey:"<API_KEY>", //Generate this <API_KEY> on Api Keys management
basicAuth: {
user: "<BASIC_AUTH_USERNAME>",
psw: "<BASIC_AUTH_PASSWORD>"
},
assistant: {
"uuid": "<DEFAULT_ASSISTANT_UUID>",
"url": "<DEFAULT_ASSISTANT_URL>",
"name": "<ASSISTANT_NAME>"
},
preferences: {
"widgetTitle" : "<WIDGET_TITLE>",
"backgroundPicture" : "<BACKGROUND_PICTURE>",
"primaryColor" : "<PRIMARY_COLOR>",
"secondaryColor": "<SECONDARY_COLOR>"
}
};
const roboAi = new RoboAi(config);
You may to specify environment too (sandbox or production), and for that you'll use js url
.
roboAi.getAssistants() // returns the available Assistants
startDialogue(assistantUuid) // returns the needed dialogueUuid
// use the dialogueUuid to sendMessage
const messageRequest = {
"format": "TEXT_PLAIN",
"message": "hello",
};
roboAi.sendMessage(dialogueUuid, messageRequest, acceptTypes.audioMp3);
Copyright 2014 - 2017 © taobao.org |