fabioberger / Mobile-Live-Chat-Support-Server

Server backend for native app live chat support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Live Chat Server

Server backend for native app live chat support written in Node.js. Includes XMPP server to respond to chat inquiries from XMPP clients. A working iOS Chat library with UI can be found here: https://github.com/soroushjp/Live-Chat-iOS-SDK

How to use:

  1. Download and install Node.js & MongoDB

  2. Start MongoDB Server

$ mongod
  1. Navigate to correct directory:
$ cd chatServer
  1. Install Chat Server dependencies:
$ npm install
  1. Start the server
$ cd chatServer
$ node server
  1. Connect to XMPP Client & Run Demo Mobile App

Native Mobile Cient-Server Protocol

Initialize Connection

Mobile Client Sends:

{
	messageType: 1,
	companyKey: INSERT_PUBLIC_KEY,
	deviceId: HASHED_MAC_ADDRESS
} 

On Success Server Returns:

{
	messageType: 1,
	agentName: AGENT_USERNAME,
	messages:
		[
			{ 
				author: "agent",
				timestamp: 1370930988910,
				content: "Hi, how may I help you?"
			}
		]
} 

Send Message

Mobile Client or Server Sends:

{
	messageType: 2,
	message:
		{ 
			author: "customer",
			timestamp: 1370930988914,
			content: "Hi, do you have this suit in grey?"
		}
} 

author: the sender (either "customer" or "agent")

On Recepit, Server/Client Returns:

{
	messageType: 4,
	request: 2,
} 

Request: the messageType of the request that was successfully received

Agent Status

Server Sends:

{
	messageType: 3,
	agent: AGENT_USERNAME,
	status: "offline"
	
} 

Status Options: offline, online, composing, paused

On Success Client Returns:

{
	messageType: 4,
	request: 3,
} 

Error Message

Mobile Client OR Server Sends:

{
	messageType: 99,
	request: 1,
	error: "Invalid Company Public Key",	
} 

Request: the messageType of the request that caused the error

About

Server backend for native app live chat support


Languages

Language:JavaScript 100.0%