1.0.9 • Published 8 years ago

botland-sdk v1.0.9

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
8 years ago

Botland SDK Node.js

Everything you need to bring to life a Botland Citizen using Node.js.

Botland is a platform for creating and deploying messaging bots on multiple messaging services at once.

Documentation

Please visit Botland SDK Node.js documentation site.

Installation

$ npm install --save botland-sdk

Usage

This SDK allows you to connect your Citizen to Botland API. You need to provide credentials in the form of an ID and token. A namespace (here assigned to botland) is exported with all classes available to fully integrate with Botland API, starting from Citizen.

Basic usage example - a bot which echoes incoming messages:

var botland = require('botland-sdk');
var Citizen = botland.Citizen;

// Replace below with citizen id and token
var citizen = new Citizen('<citizen-id>', '<token>');
citizen.start();

citizen.on('error', function(err) {
  console.log(err);
});

citizen.on('started', function() {
  console.log('Citizen connected to Botland')
});

citizen.on('message', function(message) {
  console.log('received message: %j', message);
  citizen.send(message.createReply({text: 'echo: ' + message.text}))
      .then(messageId => console.log('reply sent: %s', messageId))
      .catch(err => console.log('failed to send reply: %s', err));
});

Changelog

See Changelog.

License

Apache 2.0