Chatbot interface for university of Waterloo Open Data API with Natural Language Processing!
- User sends a message to
Mr. Goose
on Facebook - Facebook
POST
s our/webhook/
endpoint with the message and an unique User ID. - We extract the message and the User ID from the payload (logics in /
src/server.js
) - We feed the message and the User ID to the
respond
function (/src/response/respond
) then therespond
function returns a smart response. - We send the response along with the User ID back to Facebook
- Message shows up on Facebook Messenger
It seems that the respond
function has a bunch of responsability! Let's break it down
Note: We need sessions
or maybe even a DB
to track each user's activity. For example, we only want to ask our user's name once.
- A singleton that represents our chatbot's state will be instantiated when the server starts
- When
respond
function is called with anid
and amessage
, we use theid
to find if there already exits a session. Else we create a new session. Each session will be an object that stores the information of this particular user - Along with information from
session
, we usenatural
, a nodejs natural language processing library to find out what does the user want. We will have this logics in a seperate function, let's call itdecide
for now.decide
will dispatch anaction
(similar to flux right 😉) - Our action (can be async. eg. make a call to uwaterloo endpoint) will get necessary data, format message then send it back to Facebook (essentially another action).
Think it is confusing af? I totally agree
Inspired by icechen1's uwgoosebot
- Loobot does not use any proprietary third-party SaaS platform for AI or NLP.