Birthday chat bot using Node.js, Express, redis, docker and MongoDB.
The goal is to create a Facebook Messenger
bot in Node.js. The app should:
- Be able to set up a Messenger webhook
- When a user starts a conversation, ask few questions:
- User's first name
- Birth date
- If the user wants to know how many days till his next birtday. This is a yes/no answer and the bot should accept both user text answer („yes", „yeah", „yup”, "no”, "nah", etc.) and quick reply buttons. To make it simpler, you can assume there's only one valid date format: YYYY-MM-DD
- if user says yes to the last question, send him a message:
There are <N> days left until your next birthday
- if user says no, just say: Goodbye
- Within the same app, create a REST endpoint
/messages
that lists all messages received from users - Create a REST endpoint for viewing a single message by its ID and also for deleting a single message.
- Docker support
- Redis using redis for track flow of questions
- CORS enabled
- Uses yarn
- Express + MongoDB (Mongoose)
- Consistent coding styles with editorconfig
- Uses helmet to set some HTTP headers for security
- Load environment variables from .env files with dotenv
- Request validation with joi
- Gzip compression with compression
- Linting with eslint
- Tests with mocha, chai and sinon
- Code coverage with istanbul and coveralls
- Git hooks with husky
- Logging with morgan
- API documentation generation with swagger
- Monitoring with pm2
- Node v7.6+ or Docker
- Yarn
Clone the repo and make it yours:
git clone git@github.com:miladr0/steve-chat-bot.git
cd steve-chat-bot
Install dependencies:
yarn
Set environment variables:
cp .env.example .env
- To start the server:
yarn dev
- To start the server:
yarn docker:dev
From facebook developer panel set blew url as Callback URL of webhook. more info about the documentation of urls and apis. Swagger generated document .
[GET] http://localhost:3000/v1/bots/webhook
# lint code with ESLint
yarn lint
# try to fix ESLint errors
yarn lint:fix
# lint and watch for changes
yarn lint:watch
# run all tests with Mocha
yarn test
# run integration tests
yarn test:integration
# run lint and tests
yarn validate
available at:
[GET] http://localhost:3000/api-docs