/steve-chat-bot

A Facebook Messenger Chat Bot using Node.js, Express, redis, docker and MongoDB.

Primary LanguageJavaScript

Facebook Birthday chat bot

Birthday chat bot using Node.js, Express, redis, docker and MongoDB.

alt text

Goal

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:
  1. User's first name
  2. Birth date
  3. 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.

Features

Requirements

Getting Started

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

Running Locally

  • To start the server:
yarn dev

Running in Docker

  • To start the server:
yarn docker:dev

Setup webhook

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

# lint code with ESLint
yarn lint

# try to fix ESLint errors
yarn lint:fix

# lint and watch for changes
yarn lint:watch

Test

# run all tests with Mocha
yarn test

# run integration tests
yarn test:integration

Validate

# run lint and tests
yarn validate

Documents

available at:

[GET] http://localhost:3000/api-docs

alt text