Leverege Platform

Leverege Platform

  • Overview
  • JSDocs
  • REST API
  • Help

›Services

Platform Overview

  • Overview
  • Architecture
  • Core Concepts

Guides

  • Platform Setup
  • Building a Project
  • API UI

Services

  • API Server
  • Message Processor
  • Transponder
  • Reason
  • Scheduler
  • Messenger
  • Emailer
  • Rest Server
  • DB Curator

API

  • API
  • Interface
  • Project
  • System
  • Device
  • Blueprint
  • Collection
  • Child
  • History
  • Scenario
  • Script
  • Template
  • Timer
  • User
  • Users

Server Libraries

  • Log
  • Messages
  • Message Queue
  • Cache
  • Lock
  • Limit
  • Cluster Manager
  • Error
  • Exit

Utilities

  • Promise
  • Data Store
  • Factory
  • Path
  • Reasoner
  • Object Util
  • Array Util
  • String Util
  • Base62 Util
  • Value Cache
  • Validator
  • Lol

UI

  • API Redux
  • UI Builder
  • UI Elements
  • UI Redux
  • UI Mapbox Elements
  • UI Active Theme
  • UI Color Elements
  • UI Linear View Elements

Messenger

Messenger's function is to receive SMS requests in the form of an SmsMsg, queue them, and then forward them to a service that will send the SMS. Currently Messenger is configured to use the Twilio api, but Messenger can be configured for other services' apis.

Messenger listens to the messaging service set up with the Leverege Platform. The default message reading configuration is NSQ, and the topic that that Messenger listens to by default is messenger, but can be changed through environment configuration. The format of the message is a SmsMsg, which can be found in the Messages library, and an example is given below.

A message starts by invoking the route method on an instance of a writer created by Message Queue with the topic Messenger is listening to and an instance of a SmsMsg. Message Queue writes the message to the transponder service, which then routes it to this service (Messenger). Messenger does a validation check to make sure the message received is an instance of an SmsMsg. The message is then sent to Twilio for the SMS to be sent to the client.

Configuration

Required

There are 5 config variable that are required to run this service.

NameDescription
TWILIO_SIDid of Twilio account
TWILIO_AUTH_TOKENauth token for Twilio account
TWILIO_PHONEphone number messages will be sent from
MODEL_FIREBASE_SERVICE_ACCOUNTservice account key to firebase database
MODEL_FIREBASE_DATABASE_URLurl to firebase database

Optional

NameDescriptionDefault
SMS_TEMPLATES_DIRfile path to where sms templates are storednull
TRANSPORT_CONFIGconfig for readers and writers{ type, host, port }
NSQ_HOST_ADDRhost address for NSQ, not needed if TRANSPORT_CONFIG is specified'127.0.0.1'
NSQ_HOST_PORTport for NSQ, not needed if TRANSPORT_CONFIG is specified4150
CACHE_CONFIGconfiguration for the cache db{ type, connection : { host, port } }
LIMIT_CONFIGconfiguration for the limit dbLimit
MESSENGER_TOPICtopic that this service will listen to'messenger'
MESSENGER_SENDERchannel that this service will send messages on'sender'

SmsMsg

A more detailed message spec can be found in the Messages library

NameTypeDescription
recipientsstring or arrayphone number/s that will receive the SMS message
messagestring or nullmessage that will be sent
limitOptionslimitOptions or nulllimiter options that will be used for the message
templateIdstring or nullid of the template that is to be used
projectIdstring or nullLeverege Platform projectId
contextobjectprovides values to be inserted into the template

limitOptions

More detail about the limitOptions can be found in the Limit library

NameTypeDescription
countnumbermaximum number of messages that will be sent in the given period
periodnumbertime(ms) - period of time that the count will be tracked. if count is reached, stops sending the message to the user for the duration
durationnumbertime(ms) - if the count is reached in a period, user will not receive another of the message type for this amount of time
keystringnamespace key for the message
← SchedulerEmailer →
  • Configuration
  • SmsMsg
Leverege Platform
Docs
Overview
Connect
FacebookLinkedInTwitter
Facebook Open Source