1.1.8 • Published 10 years ago

hubot-wit-helper v1.1.8

Weekly downloads
76
License
MIT
Repository
github
Last release
10 years ago

hubot-wit-helper Build Status

An helper to use Wit.ai with your Hubot bot

Install npm version

npm install hubot-wit-helper

Use

Here's a basic hubot script :

'use strict';

(() => {

    const witHelper = require('hubot-wit-helper');

    const WIT_TOKEN = 'myWitToken';

    const actions = {
        say(session, context, message, cb) {

            //res object is attached to the session
            session.res.reply(message);

            cb();
        },
        merge(session, context, entities, message, cb) {
            cb(context);
        },
        error(session, context, error) {
            console.error(error.message);
            session.res.send('Something went wrong with Wit.ai :scream:');
        }
    };

    const bot = robot => {

        const witRobot = new witHelper.Robot(WIT_TOKEN, actions, robot);

        witRobot.respond(/(.*)/gi, (err, context, res) => {

            console.log(`[USER] ${witRobot.getMsg(res)}`);

            if (err) {
                console.error(err);
                return;
            }

            //do stuff
        });

    };

    module.exports = bot;

})();

License

MIT

1.1.8

10 years ago

1.1.7

10 years ago

1.1.6

10 years ago

1.1.5

10 years ago

1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago