npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

create-rc-add-in

v1.6.3

Published

Framework for RingCentral Add-In App

Downloads

209

Readme

RingCentral Add-In Framework

Build Status Latest release

The framework will help you create a RingCentral Add-In App that enables easy integration to RingCentral App.

Prerequisites

  • Download and install RingCentral App and login: https://www.ringcentral.com/apps/rc-app
  • Nodejs and npm.

Framework

This framework should be used as a boilerplate project. There are two types of Add-Ins that can be installed with this framework:

Bot

Install Bot Template

To install a bot-template, use:

npx create-rc-add-in bot

Quick Try

A bot-template would be up-and-running without any extra code. Here's how:

  1. run npm i and then npm run ngrok. We'll get https://xxxxxx.ngrok.io as our server address.
  2. Create a Bot Add-In on developer.ringcentral.com, and go to app settings. (Additional Info on creating a bot: https://developers.ringcentral.com/guide/team-messaging/bots/walkthrough)
    1. OAuth Redirect URI: https://xxxxxx.ngrok.io/bot/oauth
    2. App Permissions: Read Messages, Read Accounts, Team Messaging, Webhook Subscriptions, Edit Messages
    3. Outbound Webhook URL: https://xxxxxx.ngrok.io/interactive-messages
    4. Note down SharedSecret
  3. We'll also get ClientId and ClientSecret for the app after created. Let's then fill in .env file with:
RINGCENTRAL_CHATBOT_SERVER=https://xxxxxxx.ngrok.io

RINGCENTRAL_CHATBOT_CLIENT_ID={ClientId}

RINGCENTRAL_CHATBOT_CLIENT_SECRET={ClientSecret}

RINGCENTRAL_SERVER=https://platform.devtest.ringcentral.com

RINGCENTRAL_CHATBOT_EXPRESS_PORT=6066

RINGCENTRAL_CHATBOT_DATABASE_CONNECTION_URI=sqlite://./db.sqlite

# Credentials for admin actions
RINGCENTRAL_CHATBOT_ADMIN_USERNAME=admin
RINGCENTRAL_CHATBOT_ADMIN_PASSWORD=password

# RingCentral Add-In App interactive message shared secret
RINGCENTRAL_SHARED_SECRET={SharedSecret}
  1. Open another terminal and run npm run start
  2. On developer portal, go to your bot app's Bot tab and do Add To RingCentral
  3. Go to https://app.devtest.ringcentral.com to test it with direct message or @{yourBotName} in a team conversation with command hello and card

Development

New bot command, in src/handlers/botHandler.js, add a new case:

case 'new command':
    // send text
    const myText = '';
    await bot.sendMessage(group.id, { text: myText });
    // Or, send adaptive card. Here we use adaptive card template package, please refer to the use of it in the template
    // https://adaptivecards.io/designer/ is a great tool to design your card
    const card = {};
    await bot.sendAdaptiveCard(group.id, card);

Notification App

Install Notification App Template

This framework contains several app template variations due to the fact that different 3rd party platforms have different designs on their APIs. Before starting the installation, please:

  1. Go to 3rd party platform and register a new app there. For most platforms who have OAuth flow implementation, there will be ClientId and ClientSecret generated for your app.
  2. If 3rd party platform uses OAuth, please check if it uses accessToken + refreshToken OR just accessToken.
  3. If 3rd party platform uses OAuth, please find their API endpoints for authorization and access token exchange.

Then install a app-template with following commands:

npx create-rc-add-in app

We also have simple app-demo that are based on the template and they'll be up and running with a few steps to configure. Demos can be installed with:

npx create-rc-add-in app-demo

Use Notification App Template

To work with a plain app-template, we want to fill in our business logic in handlers which are for:

  • Authorization (authorize Add-In server with user's 3rd party platform account)
  • Subscription (create event subscription on 3rd party platform)
  • Notification (receive and format data from 3rd party platform when subscribed events happen)

Coding

Please follow the steps inside the handlers. For example, authorization handler in template looks like:

// Step.1: Get user info from 3rd party API call
const userInfoResponse = { id: "id", email: "email", name: "name"}   // [REPLACE] this line with actual call
const userId = userInfoResponse.id; // [REPLACE] this line with user id from actual response
// Find if it's existing user in our database
let user = await User.findByPk(userId);
// Step.2: If user doesn't exist, we want to create a new one
if (!user) {
    user = await User.create({
        id: userId,
        accessToken: accessToken,
        refreshToken: refreshToken,
        tokenExpiredAt: expires,
        email: userInfoResponse.email, // [REPLACE] this with actual user email in response, [DELETE] this line if user info doesn't contain email
        name: userInfoResponse.name, // [REPLACE] this with actual user name in response, [DELETE] this line if user info doesn't contain name
    });
}

Focus on [REPLACE] and [DELETE] tags. If we want to integrate Asana, then it'd be:

// Step1: Get user info from 3rd party API call
const client = Asana.Client.create().useAccessToken(accessToken); // create Asana client object
const userInfo = await client.users.me();   // call Asana to get user info
const userId = userInfo.gid; // get user id
// Find if it's existing user in our database
let user = await User.findByPk(userId);
// Step2: If user doesn't exist, we want to create a new one
if (!user) {
    await User.create({
        id: userId,
        accessToken: accessToken,
        refreshToken: refreshToken,
        tokenExpiredAt: expires
    });
}

Use Notification App Demo

It's a lot easier than using a template, and demos are essentially templates with platform-dependent logic written to implement simple functionality. Therefore a few cli commands would make it up and run.

At the moment, we have demos for Github, Asana and Gitlab.

Detailed Info

For further Information, please refer to the README.md that's inside your generated template or demo and RingCentral App Developer Guide