botkit-utterance-registry
v1.0.1
Published
Multi-platform Utterance Registry for Botkit
Downloads
1
Maintainers
Readme
Botkit Utterance Registry
This library is meant to help assist with registering utterances with botkit across multiple platforms.
Installation
$ npm install --save botkit-utterance-registry
Usage
// utterances/hello.utt.js
const events = ['message_received'];
const platforms = ['alexa', 'slack', 'fb'];
const phrases = ['hello', 'world'];
const perform = (bot, message) => {
bot.reply('hello world!');
};
export default {
platforms,
phrases,
perform,
events,
};
// utterances/index.js
import helloUtt from './hello.utt.js';
import { register } from 'botkit-utterance-registry';
register(helloUtt);
// main.js
import { addUtteranceToPlatform } from '../src/index';
import slackController from './controllers/slack';
import alexaController from './controllers/alexa';
import facebookController from './controllers/facebook';
addUtteranceToPlatform('slack', slackController);
addUtteranceToPlatform('alexa', alexaController);
addUtteranceToPlatform('fb', facebookController);
Functions
register
registers an utterance with the registry
import { register } from 'botkit-utterance-registry';
register({
platforms: ['alexa', 'slack', 'fb'],
phrases: ['hello', 'world'],
perform: (bot, message) => {},
events: ['message_received'],
});
addUtteranceToPlatform
Adds all utterances to a given platforms controller
import { addUtteranceToPlatform } from '../src/index';
import slackController from './controllers/slack';
import alexaController from './controllers/alexa';
import facebookController from './controllers/facebook';
addUtteranceToPlatform('slack', slackController);
addUtteranceToPlatform('alexa', alexaController);
addUtteranceToPlatform('fb', facebookController);
getUtteranceForPlatform
Returns all utterances registered to a given platform
import { getUtteranceForPlatform } from '../src/index';
const utterances = getUtteranceForPlatform('alexa')