Skip to content

DjioniDev/chatbot

 
 

Repository files navigation

chatbot

Facebook chatbot with NodeJs mongoose and DialogFlow.

Plugin your facebook page token and DialogFlow token in tokens.js

Table of Contents

channel

Decides which module should respond to the req depending on the contents of req.

Parameters

readWebhookEvent

Extract the webhook type

Parameters

Returns String event type

messagesGenerator

Loops over the messages

Parameters

  • messaging Object array of messages

eventsGenerator

Loops over the events

Parameters

  • entry Object array of events

textMessage

Registers user and message to database & sends message for analysis

Parameters

  • messaging JSON messaging event request

analyse

Uses apiai module to analyse input text

Parameters

  • sender string Session id used to keep track of context in apiai
  • text string text to analyse

create

Load the Tunisian city list from reference file to database

create

Add new message to database

Parameters

  • message_details object The new message key/fields pairs

create

Creates new user or update existing users messages list

Parameters

  • user_details Object new user details according to user schema
  • message_details Object new message details

cityGenerator

Iterate over the list of cities from reference file

cityCollectionExists

Look for cities collection in he current database

Returns object Resolves with true if the cities collection exists

getUserDetails

Uses facebook API to request details about the user

Parameters

Returns object a promise that resolves with the user details

read

Read user from database

Parameters

  • user object User model
  • user_details object The user to retreive from database

Returns Object User object if user exists or null otherwise

updateUserMessages

Adds a message to an existing user messages list

Parameters

  • user Object User database model
  • user_details Object User to which add the message details
  • message_details object Message to add to user

connect

Generates database connection and diconnects on process termination

About

Facebook chatbot with NodeJs mongoose and DialogFlow

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%