1.0.2 • Published 5 months ago
besperjs v1.0.2
BesperJS
BesperJS is the official JavaScript library by Besper. It provides tools to interact with B-Esper resources.
Current Functionality
- Retrieve a session token for the resource BesperBot.
Table of Contents
Installation
# Using npm
npm install besperjs
# Using yarn
yarn add besperjs
Or simply include the UMD build in your HTML:
<script src="besper.min.js"></script>
You can then access the global BesperBot object in the browser.
Usage
1. Importing/Require
If you’re using a module bundler (e.g., Webpack, Rollup, etc.) or a Node environment:
// CommonJS
const { get_session_token, VERSION } = require('besperjs');
// ES Modules
import { get_session_token, VERSION } from 'besperjs';
2. Retrieve a Session Token
(async function() {
try {
const botId = 'YOUR_BOT_ID';
const token = await get_session_token(botId);
console.log('Session Token:', token);
} catch (err) {
console.error('Error retrieving session token:', err);
}
})();
API
get_session_token(botId)
- Parameters:
botId
(string): Your unique Bot ID
- Returns: Promise - Resolves to the session token.
Example:
(async () => {
const token = await get_session_token('my-awesome-bot');
console.log(token);
})();
Contributing
- Fork this repository
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request
License
MIT