1.1.0 • Published 7 years ago

landingbot v1.1.0

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

npm version Dependency Status Code Climate

Demo

Visit my personal landing page to take it for a test drive

Installation

npm i landingbot -S

Usage

Landingbot can be used with no additional options, like below.

const Landingbot = require('landingbot');
let landingbot = new Landingbot();

However, that does not provide much functionality. You probably want to supply options like this..

const Landingbot = require('landingbot');
let landingbot = new Landingbot({
  name: 'Cambot',
  page: 'Cam\'s site',
  owner: 'Cam'
});

Additionally a slack_hook can be specified in the options, to allow for realtime correspondece via Slack. You must create an incoming webhook with Slack.

Note: This is only step one of two to enable back and forth communication from Slack to landingbot and vice versa

Want to use Custom Expressions?

Well you can do that too! The second arguement of the constructor accepts an array of objects. You can do that like this...

const Landingbot = require('landingbot');
const customExpressions = [
  {
    regex: /Is\ this\ some\ question/ig,
    question: 'Is this some question?',
    response: 'Landingbot's reply to the question'
  }
];
let landingbot = new Landingbot({
  name: 'Cambot',
  page: 'Cam\'s site',
  owner: 'Cam'
}, customExpressions);

Examples

Using landingbot on the server-side with socket.io and incorporating Slack. This example assumes your client is listening for a msg event as well as emitting one for every new message.

Have a look at this for what it may look like.

Remember how I mentioned there were two steps to enable back and forth comms within Slack? Well in this configuration the next step is as follows.. First create an outgoing webhook with Slack. Then you need your server to handle a post to whatever hook url you specified.

Take a look here for a simple example.

You may notice we are parsing for an id, that's because in the current implementation we need to prefix every message with the user's socket id. Which is provided in all their messages via an attachment.

Stay tuned for an example of client-side usage example

1.1.0

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago