From f4b4937f3a3c6953100fb0c4a3358e3d0d22080a Mon Sep 17 00:00:00 2001 From: Byrne Reese Date: Mon, 24 May 2021 17:08:25 -0700 Subject: [PATCH] Renamed Glip to Team Messaging across the board --- lib/Botkit.js | 4 +- lib/{GlipBot.js => RingCentralBot.js} | 88 +++++++++++++-------------- glip_bot.js => rc_bot.js | 6 +- readme-glip.md => readme-rc.md | 67 ++++++++++---------- readme.md | 8 +-- 5 files changed, 86 insertions(+), 87 deletions(-) rename lib/{GlipBot.js => RingCentralBot.js} (76%) rename glip_bot.js => rc_bot.js (96%) rename readme-glip.md => readme-rc.md (67%) diff --git a/lib/Botkit.js b/lib/Botkit.js index ed34bcf09..e50fc2422 100755 --- a/lib/Botkit.js +++ b/lib/Botkit.js @@ -6,7 +6,7 @@ var TwilioSMSbot = require(__dirname + '/TwilioSMSBot.js'); var BotFrameworkBot = require(__dirname + '/BotFramework.js'); var SparkBot = require(__dirname + '/CiscoSparkbot.js'); var ConsoleBot = require(__dirname + '/ConsoleBot.js'); -var GlipBot = require(__dirname + '/GlipBot.js'); +var RingCentralBot = require(__dirname + '/RingCentralBot.js'); var JabberBot = require(__dirname + '/JabberBot.js'); var WebBot = require(__dirname + '/Web.js'); @@ -20,7 +20,7 @@ module.exports = { twiliosmsbot: TwilioSMSbot, botframeworkbot: BotFrameworkBot, teamsbot: require(__dirname + '/Teams.js'), - glipbot: GlipBot, + rcbot: RingCentralBot, consolebot: ConsoleBot, jabberbot: JabberBot, socketbot: WebBot, diff --git a/lib/GlipBot.js b/lib/RingCentralBot.js similarity index 76% rename from lib/GlipBot.js rename to lib/RingCentralBot.js index 3cea4e29b..55ffe347a 100644 --- a/lib/GlipBot.js +++ b/lib/RingCentralBot.js @@ -15,14 +15,14 @@ require('events').EventEmitter.defaultMaxListeners = Infinity; var platform, subscription, rcsdk; -function Glipbot(configuration) { +function RingCentralBot(configuration) { //Create a core botkit bot - var glip_botkit = Botkit(configuration || {}); + var rc_botkit = Botkit(configuration || {}); - glip_botkit.defineBot(function (botkit, config) { + rc_botkit.defineBot(function (botkit, config) { var bot = { - type: 'glip', + type: 'ringcentral', botkit: botkit, config: config || {}, utterances: botkit.utterances, @@ -87,7 +87,7 @@ function Glipbot(configuration) { bot.send = function (message, cb) { botkit.debug('SAY', message); - platform.post('/glip/posts',{ + platform.post('/ringcentral/posts',{ groupId: message.channel, text: message.text }).then(function(response){ @@ -137,13 +137,13 @@ function Glipbot(configuration) { }); - glip_botkit.createWebhookEndpoints = function(webserver, bot, cb){ + rc_botkit.createWebhookEndpoints = function(webserver, bot, cb){ - glip_botkit.log('** Serving Webhooks endpoint for receiving messages ** ' + - 'webhooks at:' + glip_botkit.config.apiRoot + ':' + glip_botkit.config.port + '/glip/receive'); + rc_botkit.log('** Serving Webhooks endpoint for receiving messages ** ' + + 'webhooks at:' + rc_botkit.config.apiRoot + ':' + rc_botkit.config.port + '/ringcentral/receive'); - webserver.post('/glip/receive', function(req,res){ + webserver.post('/ringcentral/receive', function(req,res){ var validationToken = req.get('Validation-Token'); if(validationToken) { @@ -153,22 +153,22 @@ function Glipbot(configuration) { res.status(200).send('OK'); } else { res.status(200); - glip_botkit.handleWebhookPayload(bot, req, res); + rc_botkit.handleWebhookPayload(bot, req, res); } }); - return glip_botkit; + return rc_botkit; }; - glip_botkit.handleWebhookPayload = function(bot, req, res){ + rc_botkit.handleWebhookPayload = function(bot, req, res){ var payload = req.body; bot.res = res; - glip_botkit.ingest(bot, payload, res); + rc_botkit.ingest(bot, payload, res); } - glip_botkit.middleware.ingest.use(function(bot, message, res, next){ + rc_botkit.middleware.ingest.use(function(bot, message, res, next){ if (res && res.statusCode) { // this is an http response // always send a 200 @@ -178,7 +178,7 @@ function Glipbot(configuration) { }); - glip_botkit.middleware.normalize.use(function(bot, message, next){ + rc_botkit.middleware.normalize.use(function(bot, message, next){ message.channel = message.raw_message.body.groupId; message.user = message.raw_message.body.creatorId; message.text = message.raw_message.body.text; @@ -188,7 +188,7 @@ function Glipbot(configuration) { }); - glip_botkit.middleware.categorize.use(function(bot, message, next){ + rc_botkit.middleware.categorize.use(function(bot, message, next){ if(message.user == bot.identity.id){ return false } else{ @@ -205,11 +205,11 @@ function Glipbot(configuration) { }); - glip_botkit.middleware.receive.use(function(bot, message, next){ + rc_botkit.middleware.receive.use(function(bot, message, next){ next(); }); - glip_botkit.middleware.format.use(function(bot, message, platform_message, next) { + rc_botkit.middleware.format.use(function(bot, message, platform_message, next) { for (var key in message) { platform_message[key] = message[key]; @@ -219,42 +219,42 @@ function Glipbot(configuration) { }); - glip_botkit.configureGlipApp = function(glip_app_config, cb){ + rc_botkit.configureRingCentralApp = function(rc_app_config, cb){ - glip_botkit.log('** Configuring app as a Glip App!' + glip_app_config.clientId); - if (!glip_app_config || !glip_app_config.clientId || - !glip_app_config.clientSecret) { + rc_botkit.log('** Configuring app as a RingCentral App!' + rc_app_config.clientId); + if (!rc_app_config || !rc_app_config.clientId || + !rc_app_config.clientSecret) { throw new Error('Missing oauth config details'); } else { - glip_botkit.config.clientId = glip_app_config.clientId; - glip_botkit.config.clientSecret = glip_app_config.clientSecret; - glip_botkit.config.apiRoot = glip_app_config.apiRoot; - if (glip_app_config.redirectUri) glip_botkit.config.redirectUri = glip_app_config.redirectUri; + rc_botkit.config.clientId = rc_app_config.clientId; + rc_botkit.config.clientSecret = rc_app_config.clientSecret; + rc_botkit.config.apiRoot = rc_app_config.apiRoot; + if (rc_app_config.redirectUri) rc_botkit.config.redirectUri = rc_app_config.redirectUri; if (cb) cb(null); } - return glip_botkit; + return rc_botkit; } - glip_botkit.createOauthEndpoints = function (webserver, bot, accessToken, callback) { + rc_botkit.createOauthEndpoints = function (webserver, bot, accessToken, callback) { - console.log(glip_botkit.config.apiRoot); + console.log(rc_botkit.config.apiRoot); rcsdk = new RC({ - server: glip_botkit.config.apiRoot, - appKey: glip_botkit.config.clientId, - appSecret: glip_botkit.config.clientSecret + server: rc_botkit.config.apiRoot, + appKey: rc_botkit.config.clientId, + appSecret: rc_botkit.config.clientSecret }); platform = rcsdk.platform(); - if (!glip_botkit.config.clientId) { + if (!rc_botkit.config.clientId) { throw new Error( 'Cannot create oauth endpoints without clientId'); } - if (!glip_botkit.config.clientSecret) { + if (!rc_botkit.config.clientSecret) { throw new Error( 'Cannot create oauth endpoints without clientSecret'); } @@ -268,7 +268,7 @@ function Glipbot(configuration) { ], "deliveryMode": { "transportType": "WebHook", - "address": glip_botkit.config.redirectUri + "/glip/receive" + "address": rc_botkit.config.redirectUri + "/ringcentral/receive" }, "expiresIn": 500000000 }; @@ -277,7 +277,7 @@ function Glipbot(configuration) { .then(function (subscriptionResponse) { console.log('Subscription Response: ', subscriptionResponse.json()); subscription = subscriptionResponse; - glip_botkit.config.subscriptionId = subscriptionResponse.id; + rc_botkit.config.subscriptionId = subscriptionResponse.id; }).catch(function (e) { console.error(e); throw e; @@ -308,10 +308,10 @@ function Glipbot(configuration) { }else { platform.login({ code : req.query.code, - redirectUri : glip_botkit.config.redirectUri + '/oauth' + redirectUri : rc_botkit.config.redirectUri + '/oauth' }).then(function(authResponse){ var obj = authResponse.json(); - glip_botkit.config.accessToken = obj.access_token; + rc_botkit.config.accessToken = obj.access_token; console.log("Access Token: " + obj.access_token); res.send(authResponse.json()) getBotIdentity(bot); @@ -334,18 +334,18 @@ function Glipbot(configuration) { } } - glip_botkit.getAccessToken = function() { - return glip_botkit.config.accessToken; + rc_botkit.getAccessToken = function() { + return rc_botkit.config.accessToken; } - glip_botkit.getRCPlatform = function () { + rc_botkit.getRCPlatform = function () { return platform; } - glip_botkit.startTicking(); - return glip_botkit; + rc_botkit.startTicking(); + return rc_botkit; } -module.exports = Glipbot; +module.exports = RingCentralBot; diff --git a/glip_bot.js b/rc_bot.js similarity index 96% rename from glip_bot.js rename to rc_bot.js index 29e1e0fce..d6cfe0bb8 100644 --- a/glip_bot.js +++ b/rc_bot.js @@ -20,9 +20,9 @@ if (!process.env.CLIENT_ID || !process.env.CLIENT_SECRET || !process.env.PORT) { process.exit(1); } -var controller = Botkit.glipbot({ +var controller = Botkit.ringcentralbot({ debug: true -}).configureGlipApp({ +}).configureRingCentralApp({ clientId: process.env.CLIENT_ID, clientSecret: process.env.CLIENT_SECRET, redirectUri: process.env.REDIRECT_HOST, @@ -73,7 +73,7 @@ controller.hears(['uptime'],'message_received',function(bot, message) { var hostname = os.hostname(); var uptime = formatUptime(process.uptime()); bot.reply(message,'I am a bot! I have been running for ' + uptime + ' on ' + hostname + '.'); - //console.log('Access Token =' + controller.configureGlipApp().accessToken); + //console.log('Access Token =' + controller.configureRingCentralApp().accessToken); }); // Usage: question me diff --git a/readme-glip.md b/readme-rc.md similarity index 67% rename from readme-glip.md rename to readme-rc.md index 679164ef5..3321848e7 100644 --- a/readme-glip.md +++ b/readme-rc.md @@ -1,11 +1,10 @@ -# Botkit and Glip +# Botkit and RingCentral Team Messaging -Botkit is designed to ease the process of designing and running useful, creative bots that live inside [Glip](https://glip.com). +Botkit is designed to ease the process of designing and running useful, creative bots that live inside [RingCentral Team Messaging](https://app.ringcentral.com). -Built in to [Botkit](https://howdy.ai/botkit/) are a comprehensive set of features and tools to deal with [Glip](https://botframework.com), allowing developers to build interactive bots and applications that send and receive messages -just like real humans. +Built in to [Botkit](https://howdy.ai/botkit/) are a comprehensive set of features and tools to deal with [RingCentral Team Messaging](https://botframework.com), allowing developers to build interactive bots and applications that send and receive messages just like real humans. -This document covers the glip implementation details only. [Start here](readme.md) if you want to learn about to develop with Botkit. +This document covers the RingCentral implementation details only. [Start here](readme.md) if you want to learn about to develop with Botkit. Table of Contents @@ -22,26 +21,26 @@ Table of Contents 3) Create a .env file with the attributes below and update account information ``` - GLIP_SERVER=https://platform.devtest.ringcentral.com - GLIP_APPKEY= sandbox app key - GLIP_APPSECRET= sandbox app secret - GLIP_USERNAME= sandbox phonenumber - GLIP_PASSWORD= sandbox password - GLIP_EXTENSION= - GLIP_PORT=4000 + RINGCENTRAL_SERVER=https://platform.devtest.ringcentral.com + RINGCENTRAL_APPKEY= sandbox app key + RINGCENTRAL_APPSECRET= sandbox app secret + RINGCENTRAL_USERNAME= sandbox phonenumber + RINGCENTRAL_PASSWORD= sandbox password + RINGCENTRAL_EXTENSION= + RINGCENTRAL_PORT=4000 ``` 4) Run the example bot using the parameters mentioned above. ``` -node glip_bot.js +node rc_bot.js ``` 5) Now create another RingCentral free developer account by following #2. This account will be used to invoke the bot. -6) Go to **glip.devtest.ringcentral.com** and signin with the newly created RingCentral account. +6) Go to **app.devtest.ringcentral.com** and signin with the newly created RingCentral account. -6) Enter the **username**, **password** and **extension** to login to glip. +6) Enter the **username**, **password** and **extension** to login to RingCentral. 7) Invite the bot using the email address. @@ -52,7 +51,7 @@ Try the following commands: * pizzatime -## Glip Specific Events +## RingCentral Team Messaging-specific Events Once connected to the Bot Framework, bots receive a constant stream of events. @@ -62,18 +61,18 @@ Normal messages will be sent to your bot using the `message_received` event. In |--- |--- | message_received | A message was received by the bot. -All incoming events will contain the fields `user` and `channel`, both of which represent the glip user's ID, and a `groupid` field. +All incoming events will contain the fields `user` and `channel`, both of which represent the user's ID, and a `groupid` field. `message_received` events will also contain either a `text` field or an `attachment` field. -## Working with Glip +## Working with RingCentral Team Messaging -Botkit receives messages from the glip adapters using pubnub subscriptions, and posts messages to glip using APIs. This means that your bot application must present a web server that is publicly addressable. Everything you need to get started is already included in Botkit. +Botkit receives messages from the RingCentral adapters using pubnub subscriptions, and posts messages to RingCentral using APIs. This means that your bot application must present a web server that is publicly addressable. Everything you need to get started is already included in Botkit. -To connect your bot to Glip follow the step by step guide outlined in [Getting Started](#getting-started). +To connect your bot to RingCentral follow the step by step guide outlined in [Getting Started](#getting-started). -Here is the complete code for a basic Glip bot: +Here is the complete code for a basic RingCentral Team Messaging bot: ```javascript var Botkit = require('./lib/Botkit.js'); @@ -81,20 +80,19 @@ var os = require('os'); var http = require('http'); var request = require('request'); - -var controller = Botkit.glipbot({ +var controller = Botkit.rcbot({ debug: false, }); var bot = controller.spawn({ - server: process.env.GLIP_SERVER, - appKey: process.env.GLIP_APPKEY, - appSecret: process.env.GLIP_APPSECRET, - appName: 'GlipDemo', + server: process.env.RINGCENTRAL_SERVER, + appKey: process.env.RINGCENTRAL_APPKEY, + appSecret: process.env.RINGCENTRAL_APPSECRET, + appName: 'RingCentralDemo', appVersion: '1.0.0', - username: process.env.GLIP_USERNAME, - password: process.env.GLIP_PASSWORD, - extension: process.env.GLIP_EXTENSION, + username: process.env.RINGCENTRAL_USERNAME, + password: process.env.RINGCENTRAL_PASSWORD, + extension: process.env.RINGCENTRAL_EXTENSION, }).startRTM(); // if you are already using Express, you can use your own server instance... @@ -149,12 +147,13 @@ var askWhereDeliver = function(response, convo) { }); } ``` -#### Botkit.glipbot() +#### Botkit.rcbot() + | Argument | Description |--- |--- | settings | Options used to configure the bot. -Creates a new instance of the bots controller. The controller will create a new instance of the GlipConnector. so any options needed to configure the glip should be passed in via the `settings` argument. +Creates a new instance of the bots controller. The controller will create a new instance of the RingCentralConnector. Therefore, any options needed to configure the RingCentral bot should be passed in via the `settings` argument. #### controller.setupWebserver() | Argument | Description @@ -173,7 +172,7 @@ which may be used to add further web server routes. #### controller.createWebhookEndpoints() -This function configures the route `https://_your_server_/glip/receive` -to receive webhooks from glip. +This function configures the route `https://_your_server_/ringcentral/receive` +to receive webhooks from RingCentral. diff --git a/readme.md b/readme.md index 57fb731e8..04bb92cb3 100644 --- a/readme.md +++ b/readme.md @@ -29,7 +29,7 @@ Plus, Botkit works with all the NLP services (like Microsoft LUIS and IBM Watson * [Twilio SMS Messaging](docs/readme-twiliosms.md) * [Twilio IP Messaging](docs/readme-twilioipm.md) * [Microsoft Bot Framework](docs/readme-botframework.md) -* [Glip](readme-glip.md) +* [RingCentral Team Messaging](readme-rc.md) * Yours? [info@howdy.ai](mailto:info@howdy.ai) Botkit is a Node.js module, and works with Node and npm. @@ -68,7 +68,7 @@ are ready to submit to [Cisco Spark's Depot app store](https://depot.ciscospark. > ### [Facebook Bot Starter Kit](https://github.com/howdyai/botkit-starter-facebook) > The Facebook starter kit contains all the code necessary to stand up a Facebook bot on either Facebook Messenger, or Facebook Work Chat. With just a few pieces of configuration, set up a bot that automatically responds to messages sent to your Facebook page. > #### [![Remix on Glitch](docs/glitch.png)](https://glitch.com/edit/#!/import/github/howdyai/botkit-starter-facebook) -If you intend to create a bot that lives in Glip, [follow these instructions for configuring your Glip bot](readme-glip.md#getting-started). +If you intend to create a bot that lives in RingCentral Team Messaging, [follow these instructions for configuring your bot](readme-rc.md#getting-started). If you intend to create a bot that lives inside a Twilio IP Messaging client, [follow these instructions for configuring your app](readme-twilioipm.md#getting-started). > #### [![Remix on Glitch](docs/glitch.png)](https://glitch.com/~botkit-facebook) @@ -192,7 +192,7 @@ controller.middleware.send.use(function(bot, message, next) { * [Twilio SMS](docs/readme-twiliosms.md) * [Twilio IPM](docs/readme-twilioipm.md) * [Microsoft Bot Framework](docs/readme-botframework.md) - * [Glip Messaging](https://developer.ringcentral.com/library/getting-started.html) + * [RingCentral Team Messaging](https://developer.ringcentral.com/guide/) * [Web and Apps](https://botkit.ai/docs/readme-web.html) * [Slack](https://botkit.ai/docs/readme-slack.html) @@ -203,7 +203,7 @@ controller.middleware.send.use(function(bot, message, next) { * [Twilio SMS](https://botkit.ai/docs/readme-twiliosms.html) * [Twilio IPM](https://botkit.ai/docs/readme-twilioipm.html) * [Microsoft Bot Framework](https://botkit.ai/docs/readme-botframework.html) - * [Glip Messaging](https://developer.ringcentral.com/library/getting-started.html) + * [RingCentral Team Messaging](https://developer.ringcentral.com/guide/) * [Extending Botkit with Plugins and Middleware](https://botkit.ai/docs/middleware.html) * [Message Pipeline](https://botkit.ai/docs/readme-pipeline.html) * [List of current plugins](https://botkit.ai/docs/readme-middlewares.html)