generator-spark-botis a yeoman generator that scaffolds out a node Cisco Spark bot following an
event-drivenfashion, and is extremely easy to get started with.
trigger context => callback()
Designed with simplicity and usability in mind:
- Fast to get started, just drop a
/commandsand your bot will register a listener on start
- Easier unit testing with access to commands' private methods
- Includes Flint for a more robust framework
Ensure yeoman is is installed:
npm install -g yo or
yarn global add yo
After yeoman is installed:
. ├── commands # Event handlers are within the commands │ └── example.js # An example command for reference ├── app.js # Bot entry point ├── config.js # Configurations ├── test.js # AVA Test ├── readme.md ├── license └── package.json
A command sub-generator [yo spark-bot:command] is soon to come
Commands will instruct the bot on when and how to respond to particular contextual triggers.
To add a command, simply add a
.js file within the commands directory. When the bot is initializing, commands will automatically register with Flint at runtime.
These command must implement an interface that contains a
trigger property and a
callback method. Refer to
example.js within the commands directory.
The contextual trigger that will cause the bot to execute the callback upon matches.
The function to be executed (event handler).
npm run test- Run linter and unit test
npm start- Start the bot
npm run debug- Activate debugging to log
Unit testing is straightforward, simple, and already configured with the AVA test runner. Commands are accessible through the
fileName as a property of the
commands object. Thus, any command callbacks can be tested as such:
In addition, the
rewire module is pre-configured to test private methods and is easily accessible without the need of exporting any private methods. This is done with the
__get__() method. IE:
- Express - Fast, unopinionated, minimalist web framework for node.
- Flint - Cisco Spark Bot SDK for Node JS
MIT © Brandon Him