Introduction
Bots can be built using Node.js in two ways:
- Use the Symphony bot generator. Launch the generator, choose the Node.js language and select your template.
- Use the Symphony Node.js client npm package symphony-api-client-node. You can add this as a dependency of your Node.js application.
The remainder of this document describes the Symphony Node.js client npm package.
Installing the Symphony Node.js Client npm Package
Execute the following command to install the package:
npm install --save symphony-api-client-node
Usage
const Symphony = require('symphony-api-client-node');
const botHearsSomething = ( event, messages ) => {
messages.forEach( (message, index) => {
console.log( 'The BOT heard "' + message.messageText +'" from ' + message.initiator.user.displayName );
})
}
Symphony.initBot(__dirname + '/config.json')
.then( (symAuth) => {
Symphony.getDatafeedEventsService( botHearsSomething );
})
Setting the debug mode to see traces
Symphony.setDebugMode( true );
Updated about a year ago