This was created as a template to get quickly started with a slack bot. It utilizes Express.js, mongoose & typegoose to provide a low barrier of entry.
Checkout below for more info.
This application requires the LTS version of NodeJS as well as MongoDB v4.2.1 or higher (not guaranteed to work with lower versions!).
- Install LTS version of NodeJS
- In the root directory, run
npm install
to get all dependencies - Done!
The bot requires a file src/config/config.json
with the following base format:
{
"slack": {
"bot_oauth_token": "YOUR-BOT-OAUTH-TOKEN",
"verification_token": "YOUR-SLACK-VERIFICATION-TOKEN",
"bot_id": "BOT-ID",
"bot_name": "BOT-NAME",
"messaging": {
"chatMessage": "https://slack.com/api/chat.postMessage"
}
}
}
The bot_token
and slack_token
fields are optional. If they are not provided, the following environment variables will be used in their place:
bot_oauth_token
->MANDO_BOT_TOKEN
verification_token
->MANDO_SLACK_TOKEN
The file src/config/db_config.json
helps initialize a connection to MongoDB. The following is the base format:
{
"mongo_db": {
"url": "mongodb://localhost/",
"port": "27017",
"database": "mando_bot"
}
}
For additional information on getting started, take a look at the Bot Users setup guide and the Events API.
Run npm test
to execute the entire test suite.
Run npm run dev
to start the server in development mode.
- Build JS Bundle:
npm run build
- Start server:
NODE_ENV=production node ./build/index.js
All build assets are located in build/
.
All logging will be sent to the console when running in dev. When in production, all logs are combined into a single file and placed in
- App Logs:
build/logs/logs_{current_date_time}.log
. - CRON Jobs:
build/logs/cron_logs_{current_date_time}.log