beekeeper
v0.15.2
Published
A library wrapping requests to the Beekeeper API for easy access
Downloads
512
Readme
Beekeeper JavaScript SDK
An API wrapper for Beekeeper to give easy access to services from the ecosystem. This library can be used on the client and server. Please see required adoption below.
Beekeeper is a mobile-first communication platform that reaches every shift, location, and language through real-time messaging and targeted streams. Managers keep frontline teams productive and turnover low by automating workflows, while leveraging an analytics dashboard to measure engagement. Beekeeper integrates with existing operational systems and makes them accessible in one central portal.
Learn more about Beekeeper at https://beekeeper.io.
Installation
Install NPM package with:
$ yarn add beekeeper // npm install --save beekeeper
Optional dependencies
Some features require additional dependencies:
If you are using this package with Node.js, please also add the optional dependency node-fetch
:
$ yarn add node-fetch
If you want to use the realtime capabilities (e.g. Chatbots), please also add the optional dependency pubnub
;
$ yarn add pubnub
If you need to upload files, please also add the optional dependency axios
:
$ yarn add axios
If you need to upload files and the project is running on Node.js form-data
is required in addition to axios
:
$ yarn add form-data
Tenant Access
In order to use this package on a tenant, you will need to gather two pieces of information:
- Tenant URL e.g.
https://tenant.beekeeper.io
- Bot Access Key e.g.
fae00bbc-b0f6-4ace-8e13-7d53b58076e1
Read more about it in the Help Center.
SDK API
The SDK gives access to multiple domains at Beekeeper. Here are the different resources.
General
sdk.getMe()
gets information about the current user
Messages
sdk.Messages.create(message)
creates a new message
Profiles
sdk.Profiles.get(username)
gets a profile by usernamesdk.Profiles.list(filter)
returns a list of users with optional filter that can be {limit: 50}. This is an ADMIN resource.
Conversations
sdk.Conversations.byProfile(profile)
gets a conversation by username
Posts
sdk.Posts.create(post)
create a new post
Streams
sdk.Streams.list()
gets a list of streams
Files
sdk.Files.create()
uploads a file
Artifacts
sdk.Artifacts.get(query)
returns a root artifact with optional query that can be
{ expand: 'children' | 'breadcrumbs' | 'acl', visibility: 'read' | 'manage' }
sdk.Artifacts.getById(artifactId, query)
gets the artifact by artifactId with optional query that can be
{ expand: 'children' | 'breadcrumbs' | 'acl', visibility: 'read' | 'manage' }
sdk.Artifacts.getAclById(artifactId)
gets the Acl by artifactId
sdk.Artifacts.create(artifactId, body, query)
creates a new artifact by artifactId with optional query that can be
{ expand: 'children' | 'breadcrumbs' | 'acl' }
sdk.Artifacts.update(artifactId, body, query)
updates an existing artifact with optional query that can be
{ expand: 'children' | 'breadcrumbs' | 'acl' }
sdk.Artifacts.updateAcl(artifactId, body)
updates existing acl on an artifact
sdk.Artifacts.delete(artifactId)
deletes an existing artifact
ChatBot
An easy way to get started with the Beekeeper SDK is a chatbot. An example is shown below:
const { ChatBot } = require('beekeeper');
const credentials = {
tenantURL: 'https://<tenant>.beekeeper.io',
token: '540a254c-ea8b-4ae7-a456-d8437b7314d6',
};
const bot = ChatBot.withCredentials(credentials);
bot.on('message', (message, ctx) => {
// Listen to new messages and reply with received text
ctx.replyWithText(message.text);
});
bot.on('started', () => {
// Listen for started event and indicate readiness
console.log('Bot is started!');
});
// Start listening for events
bot.start();
More examples can be found in the examples folder.