Coder Social home page Coder Social logo

message-dispatcher's Introduction

Message-Dispatcher

Message-Dispatcher is a demo app that allows a RingCentral admin user to subscribe to all extensions within your RingCentral account. This enables the app to listen to presence events for extensions within your account and to dispatch a message ( send SMS ) when specific numbers are dialled. For more information, read the RingCentral Developer Guide - Notifications and Subscriptions.

Prerequisites

Installation

Clone the repository to your local system: [Optionally, you can fork it first, but will need to modify the URI in the following command to match your fork's GIT repository.]

git clone https://github.com/anilkumarbp/Message-Dispatcher.git

Change your working directory to the newly cloned repository:

cd Message-Dispatcher

Install dependencies using NPM:

npm install

Define an Application in RingCentral

In order to communicate with the RingCentral API, you will need to have RingCentral API Keys for the appropriate environment, either Sandbox or Production.

**IMPORTANT NOTE: The Device permission listed below is not currently available through special request. Please Submit a Support Request using the Developer Portal please reference that you are using the Message-Dispatcher module created by the RingCentral Developer Community, and request access for this permission to be added to your application. Make sure to include your Application Name in your request.

NOTE: Since this application is server-side only, this value is not important. The OAuth Redirect URI value recommended below is only for development purposes on your local computer.

  1. Login to the Developer Portal https://developer.ringcentral.com/login.html#/ if you haven't already.
  2. Click on 'Create App' to define a new application, here are the recommended parameters to operate with Message-Dispatcher:
    • Application Name: Your choice, but something easy to identify and associate with purpose is good
    • Application Type: Private
    • Platform Type: Embedded
    • Permissions Needed:
      • Read Accounts
      • SMS
    • OAuth Redirect URI: http://localhost:3000
  3. Once you have successfully defined your application, you will need to obtain the API Credentials for your application to use in Development Environment Setup in the next steps. The API Key and API Secret values are accessible to you in the Credentials section for your application in the RingCentral Developer Portal.

Development Environment Setup

Before operating the application for local development and testing, you will need to configure some RingCentral-specific environment variables.

You will need to create a .env file in the root directory of this application. We have created a file you can use as a template named TMP.env. Below are the steps to setup your development environment:

  1. Rename .env.tmpl to .env. From the terminal in Mac or Linux environments: mv .env.tmpl .env

  2. Open the .env for editing

  3. Enter the indicated values:

    TC_Accounts

    • RC_USERNAME= Admin user's phone number
    • RC_PASSWORD= Admin user's password
    • RC_EXTENSION= Admin user's extension
    • RC_APP_KEY= Your application's app_key
    • RC_APP_SECRET= Your application's app_secret
    • RC_ENVIRONMENT= Either sandbox -OR- production
    • RC_API_BASE_URL= Only change when your application receives production access
    • RC_CACHE_PREFIX= To identify that it is an RC Account for the platform object

    SA_Accounts

    • SA_USERNAME= Service Account user's phone number
    • SA_PASSWORD= Service Account user's password
    • SA_EXTENSION= Service Account user's extension
    • SA_APP_KEY= Service Account application app_key
    • SA_APP_SECRET= Service Account application user's password
    • SA_ENVIRONMENT= Either sandbox -OR- production
    • SA_API_BASE_URL= Only change when your application receives production access
    • SA_CACHE_PREFIX= To identify that it is SA Account for the platform object

    Call Filter Details

    • ALERT_SMS= Array of phone numbers for people you want to wake up with alerts ex: ["xxxxxxxxxx","xxxxxxxxxx"]
    • SOURCE_PHONE_NUMBER= Source phone number of the alert
    • PORT= The port the HTTP server will listen upon
    • FILTER_DIRECTION= Either Outbound || Inbound the direction of phone calls
    • FILTER_TO= 411 || 511 || 911 (ONLY USE 911 in Production)
    • FILTER_DEVICE_TYPE= Array of phone type elements as strings, one of: HardPhone, SoftPhone, OtherPhone
    • DEVICES_PER_PAGE= Number for page aggregation, uses 500 by default

    USAGE PLAN LIMITS

    • MAX_DEVICES_PER_MIN= Number of maximum devices for the Rate Limit throttling

Operation

To start this application locally:

npm start

To run the unit tests:

npm test

Dependencies

Current used RCSDK version for this demo is : RCSDK-2.0.4

  • Make sure to change the SDK version in the package.json before you chose to use a different SDK Version.

Links

Project Repo

RingCentral SDK for JavaScript

RingCentral API Docs

RingCentral API Explorer

Contributions

Any reports of problems, comments or suggestions are most welcome.

Please report these on Message-Dispatcher's Issue Tracker in Github.

License

RingCentral SDK is available under an MIT-style license. See LICENSE.txt for details.

RingCentral SDK © 2016 by RingCentral

FAQ

message-dispatcher's People

Contributors

anilkumarbp avatar bdeanindy avatar creatovisguru avatar daisyi avatar grokify avatar kirill-konshin avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

message-dispatcher's Issues

Move configuration and credential data to Environment variables

Having API keys, application configuration and shaping values defined in the application is not recommended.

Instead, we can use the dotenv module to externalize these values. This simplifies developing locally and without need of including CLI options as well as providing a more consistent interface when deploying to the cloud in a multi-instance scenario.

Fix .env.tmpl hostname

Change:

https://platform.devtest.ringcintral.com

to:

https://platform.devtest.ringcentral.com

See pull request.

Need to parse ALERT_SMS as a string then split

The ALERT_SMS environment variable is currently listed in the template as an array, but if you use the array and have more than one element, the property returns as undefined and causes a parse error.

Would be best (since this is a limitation of the dotenv module) to just load a comma separated list of numbers and then use JS to split on the comma. This should solve that problem.

Improve README

README to include testing, contributing, getting started, submitting issues, use-case example w/ demo

Abstract Event Monitor into discrete module:

Expects eventFilter array to be provided to operate
- Expects dataFormatter to be provided to operate
- Expects filterCriteria to be provided to operate
- Manages Subscription (CRUD operations)
- Manages CRUD operations for eventFilters
- Broadcasts data in format provided by dataFormatter when filterCriteria are met

Console reporter to sysadmin has looping scope issues

The following messages need to have the loops scoped within a closure to properly provide valid information:

  1. "************* Retreived 156 : devices so far ************"
    ^^^ Same ID keeps showing for all
  2. "The Device : 15204835020 has no emergency address attached to it. Kindly Add the Emergency Address to it."
    ^^^ Same ID keeps showing for all

Subscription Notification Message - fromNumber is 'undefined'

Was watching the customer's execution of this, and noticed that the 'fromNumber' in the SMS message was shown as undefined. This value is critical to looking up emergency address data by their staff, when the emergency address information is missing from device API resource.

Switch to MIT license

This is the standard licensing which is used by any RingCentral-related community-focused tools, sample applications and code resources.

Subscription Notification Handler references undefined variable

Customer reported the following...

“Hi again. I made the changes to the config file (which were previously uncommunicated to us). I started the app at 11:43am, and was able to get a test notification out after about 20 minutes. So that's the good news.

The bad news is the app just crashed again, with the same error as before... about 23 minutes after starting it.

TypeError: Cannot read property '0' of undefined
at Subscription.handleSubscriptionNotification (/home/ec2-user/Message-Dispatcher/index.js:449:50)

Timer issue

Per @anilkumarbp :
Line number 100 within my index.js where I am trying to re-call the async method to Active-call API but I get a timer._repeat error.

Abstract Alert Dispatcher into discrete module:

Defaults to RingCentral SMS as outbound channel
- Exposes “addHttpAlert” method which expects:
- name, description, uri, xHeaderName, xHeaderValue
- Subscribes to events provided by external source (in our case Event Monitor)
- Delivers registered alerts to appropriate channels defined in each instance
- Maintains list of channels to alert (if SMS, expects one or more phone numbers in valid format)

Missing sleep module in package.json

The sleep module is used within index.js but it is not referenced in the package.json file.

Please run npm install --save sleep to ensure this module is written to the package file and usable by developers when they execute the npm install command.

Need to capture Location

The SMS being sent needs to have the location information to be of value, will need to lookup Emergency information with: extensionNumber, phoneNumber, location and name of person to populate SMS text.

Emit log data when filtered list contains missing emergency contact info

As part of the requirements to address this use case, each physical device is expected to have an Emergency Address assigned for every device.

MUST HAVE: To ensure this code does not fail and abort execution, proper sanity checks should be added with a customer-defined set of minimal intelligent defaults in these types of error conditions.

NICE TO HAVE: Adding logs for each device in the filtered (monitored) list, which does not contain this vital information. This will help Teacher's College to identify accounts which do not meet the necessary criteria for their First-Response monitoring needs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.