buddhy-botkit
v0.0.2
Published
A botkit-based Slack bot for Zendesk Inbox
Downloads
3
Readme
Buddhy-botkit
A botkit-based Slack bot for Inbox development.
Running
The following environment variables are things you'll need.
You can put them in a .env
file.
You can also use /secrets
; a file called /secrets/FOO
with content bar
is the same as setting FOO=bar
in the environment.
SLACK_TOKEN
- REQUIRED This connects the app to a Slack bot user.BRAIN_JSON_DIR
- Stores Buddhy's brain in a directory of JSON files. (Useful for development.) Use./brain
for a clean git status.BRAIN_REDIS_URL
- Stores Buddhy's brain in Redis.BING_ACCOUNT_KEY
- for Bing search API, including images (and pugs).WUNDERGROUND_KEY
- for weather services
Hacking
Pull requests welcome.
Running locally
$ echo 'SHELLBOT=1' >> .env
$ npm install
$ npm run dev
This will start up nodemon, so it'll restart on file changes.
You'll interact with the bot using the shell.
Type \?
to get help on the shell's commands.
If you're running VS Code, you can just hit F5, but you'll have to manually restart when you change something. The shellbot doesn't work so well in this mode, though.
Writing scripts
If you want to write a Buddhy script, here's what you need to know.
First, add a new file under the scripts
directory.
Every file in there is automatically loaded when the bot starts up.
Your script file's module.exports
should have these items in it:
init
- a function that takes a Botkit controller as an argument. This is where you add listeners (usingcontroller.hears
) and reply to commands.help
- An array of strings, which describe the commands your module implements. This is searched when a user asks the bot for help.web
- a function that takes an Express application object as an argument. Here you can add handlers for HTTP endpoints on the bot, for configuration UI, OAuth, or anything else. (Experimental.)
You can export anything else at all, but it'll be ignored by the bot.
To preview what your message will look like in Slack
Use Slack's Message Builder.
Testing
Export testable functions or objects from your module, and write a test module in the tests
directory.
Run the tests with npm test
, which will also run the StandardJS linter.