Bot Libre Forum Sign In : Sign Up

How to use the Bot Libre nodejs SDK

by OmarBajunaid posted Nov 29 2023, 23:17

The Bot Libre Nodjs SDK allows you to easily integrate Bot Libre with a nodjs application. Through the SDK you can connect to your bots on Bot Libre, send messages, and train and configure your bots. You can also access Bot Libre analytics and AI services, and other content. Start by setting the 'Application ID', 'username' and 'password' are required. If you don't have an account yet, you can create one at botlibre. You can get an application ID from any of the services websites (Bot Libre, Bot Libre for Business).

Getting Started

Prerequisits

  • Nodejs
  • npm (Node Package Manager)

Installation

Clone the Bot Libre python SDK by clicking on this link:https://github.com/BotLibre/BotLibre/tree/master/sdk/nodejs

Navigate to the project directory

cd nodejs

Install dependencies

npm install

Note

Including separate scripts for development and production, with the development script utilizing nodemon for automatic server restarts.

Scripts

Start application for development

npm run dev

The "dev" script uses nodemon to watch for changes in your TypeScript files and automatically restarts the server when changes occur. It executes the TypeScript files directly using ts-node.

Start application for production

npm start

The "start" script runs the compiled JavaScript files in the dist directory using Node.js.

After executing the command npm run dev, carefully observe the nodemon verbose output to ensure that you encounter the following message:

[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: ts,json
[nodemon] starting `ts-node src/server.ts`
Server is running on http://localhost:3000

Open your browser and navigate to 'localhost:3000.' Ensure that the page loads correctly.

  • Once you have obtained your Credentials, you can start by testing the API's/connect and /chat respectively, by selecting them from the dropdown menu above. /connect is used to log the user in and establish a new token, which will be saved as a cookie in the browser.
    Note: Once the user has logged in, there's no need to use the /connect endpoint again every time. Instead, you can proceed with other operations, such as using the /chat endpoint.
  • You will need 'Application ID', 'username' and 'password'. If you don't have an account yet, you can create one at botlibre. You can get an application ID from any of the services websites (Bot Libre, Bot Libre for Business).

Important: Before trying other api calls, most of them require additional attributes, which needs to be entered manually. Please review the file index.html for further details. Take a moment to review the cases within the switch statement in the executeAPI function. Feel free to explore and edit them as needed.


Id: 50497826
Posted: Nov 29 2023, 23:17
Replies: 0
Views: 590, today: 3, week: 19, month: 129