<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Embbnux Ji on Medium]]></title>
        <description><![CDATA[Stories by Embbnux Ji on Medium]]></description>
        <link>https://medium.com/@embbnux?source=rss-deab83a07f35------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1UqlulXzvnR08cLK-PlIwg.jpeg</url>
            <title>Stories by Embbnux Ji on Medium</title>
            <link>https://medium.com/@embbnux?source=rss-deab83a07f35------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 20:29:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@embbnux/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building Chrome Extension (Manifest V3) with RingCentral Embeddable]]></title>
            <link>https://medium.com/ringcentral-developers/building-chrome-extension-manifest-v3-with-ringcentral-embeddable-f0ace34946c3?source=rss-deab83a07f35------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0ace34946c3</guid>
            <category><![CDATA[ringcentral-embeddable]]></category>
            <category><![CDATA[chrome-extension]]></category>
            <category><![CDATA[manifest-v3]]></category>
            <dc:creator><![CDATA[Embbnux Ji]]></dc:creator>
            <pubDate>Wed, 27 Sep 2023 21:44:39 GMT</pubDate>
            <atom:updated>2023-09-27T21:44:39.388Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r9GHP5leNmGkHmEV2SqBnA.png" /><figcaption>RingCentral Embeddable Chrome extension demo</figcaption></figure><p>In <a href="https://medium.com/ringcentral-developers/build-a-chrome-extension-with-ringcentral-embeddable-bb6faee808a3">our earlier blog</a>, we explored the seamless integration of RingCentral Embeddable with Chrome extension manifest V2. Now Chrome introduces the new manifest V3, and requires developers to upgrade. In this blog, we will dive into the process of building a Chrome extension using Manifest V3, while integrating RingCentral Embeddable for efficient communication within web apps.</p><h3>Understanding Chrome Extension Manifest V3</h3><p>Manifest V3 is the latest version of the manifest file that defines the structure and behavior of a Chrome extension. It offers enhanced security and performance, making extensions more reliable and user-friendly. Unlike Manifest V2, V3 enforces a declarative approach to extension architecture, providing better isolation between components. Chrome extension support for manifest V2 will be discontinued in 2024.</p><p><strong>Breaking Changes when upgrade to Manifest V3</strong></p><ol><li>Background pages to service workers (no persistence)</li><li>No remote codes (no load scripts from no local files)</li></ol><p><strong>Relate links</strong></p><ul><li>Chrome manifest V3 <a href="https://developer.chrome.com/docs/extensions/migrating/">migration document</a></li></ul><h3>Introducing RingCentral Embeddable</h3><p>RingCentral Embeddable is a suite of tools that allow developers to seamlessly integrate communication features, such as voice and video calls, messaging, and meetings, directly into web applications. This integration enhances user productivity by eliminating the need to switch between different platforms for communication.</p><p><strong>Relate links</strong></p><ul><li>Github repository and document: <a href="https://github.com/ringcentral/ringcentral-embeddable">RingCentral Embeddable</a></li></ul><h3>Prerequisites for Building the Extension</h3><p>Before diving into the development process, ensure you have a basic understanding of JavaScript, HTML, and Chrome extension concepts. Additionally, sign up for a free <a href="https://developers.ringcentral.com/">RingCentral developer account </a>to access the necessary API credentials.</p><h3>Step-by-Step Guide</h3><h4>Setting up the Extension Directory</h4><p>Firstly, please create a directory for your extension project with following file structures. For files, we can just keep them blank, we will implement them in the next section.</p><p>├── embeddable<br>│ ├── app.js<br>│ ├── app.html<br>├── images<br>├── c2d<br>│ ├── index.js<br>├── manifest.json<br>├── background.js<br>├── content.js<br>├── popup.js<br>├── popup.html</p><p>As manifest V3 doesn’t allow for remote loading of javascript files, we need to include prebuilt embeddable files in the project.</p><p>The embeddable folder is the prebuilt files of RingCentral Embeddable for Chrome extension. Please download from <a href="https://github.com/ringcentral/ringcentral-embeddable/archive/refs/heads/extension-build.zip">here</a> to ensure you have the latest version.</p><p>The c2d folder is only required when you would like to add Click To Dial/SMS features for the Chrome extension. You can get c2d/index.js from <a href="https://unpkg.com/ringcentral-c2d@1.0.0/build/index.js">here</a>.</p><h4>Defining the Manifest File:</h4><p>Add the following code into your manifest.json file:</p><pre>{<br>  &quot;name&quot;: &quot;RingCentral Embeddable Demo&quot;,<br>  &quot;description&quot;: &quot;A RingCentral Embeddable extension demo&quot;,<br>  &quot;version&quot;: &quot;0.0.1&quot;,<br>  &quot;permissions&quot;: [<br>    &quot;storage&quot;,<br>    &quot;alarms&quot;,<br>    &quot;identity&quot;,<br>    &quot;activeTab&quot;,<br>    &quot;tabs&quot;,<br>    &quot;background&quot;,<br>    &quot;tabCapture&quot;,<br>    &quot;unlimitedStorage&quot;<br>  ],<br>  &quot;host_permissions&quot;: [<br>    &quot;https://contacts.google.com/*&quot;<br>  ],<br>  &quot;content_scripts&quot;: [<br>    {<br>      &quot;matches&quot;: [&quot;https://contacts.google.com/*&quot;],<br>      &quot;js&quot;: [<br>        &quot;./c2d/index.js&quot;,<br>        &quot;./content.js&quot;<br>      ]<br>    }<br>  ],<br>  &quot;web_accessible_resources&quot;: [<br>    {<br>      &quot;resources&quot;: [&quot;/embeddable/*&quot;, &quot;/c2d/*&quot;],<br>      &quot;matches&quot;: [&quot;https://contacts.google.com/*&quot;]<br>    }<br>  ],<br>  &quot;action&quot;: {<br>    &quot;default_icon&quot;: {<br>      &quot;16&quot;: &quot;/images/logo16.png&quot;,<br>      &quot;32&quot;: &quot;/images/logo32.png&quot;,<br>      &quot;48&quot;: &quot;/images/logo48.png&quot;,<br>      &quot;128&quot;: &quot;/images/logo128.png&quot;<br>    }<br>  },<br>  &quot;background&quot;: {<br>    &quot;service_worker&quot;: &quot;background.js&quot;<br>  },<br>  &quot;content_security_policy&quot;: {<br>    &quot;extension_pages&quot;: &quot;script-src &#39;self&#39;; object-src &#39;self&#39;&quot;<br>  },<br>  &quot;manifest_version&quot;: 3,<br>  &quot;icons&quot;: {<br>    &quot;16&quot;: &quot;/images/logo16.png&quot;,<br>    &quot;32&quot;: &quot;/images/logo32.png&quot;,<br>    &quot;48&quot;: &quot;/images/logo48.png&quot;,<br>    &quot;128&quot;: &quot;/images/logo128.png&quot;<br>  }<br>}</pre><p>From V2, we change background scripts to service worker . Please keep in mind that the worker is not persistent. It may be stopped and restarted. So every variable in memory will be lost. We need to use storage persistence for some variables.</p><p>We also declare “content_scripts” and “web_accessible_resources” as we will integrate the embeddable widget into the Google contacts page as part of this demo project. You need to change the domain to what you want to integrate.</p><p>After the manifest file is created, we can try to install it into Chrome for testing. Go to “chrome://extensions/”, enable developer mode, and click Load unpacked to install the extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*f3jvfSifq92AWzNxmqqojw.png" /><figcaption>RingCentral Embeddable demo extension</figcaption></figure><h4>Setup popup window</h4><p>For Chrome extension, we recommend to integrate the embeddable widget as a popup window, not inside the web page. With the popup window, the call will be kept connected even if the user refreshes or close web pages.</p><p>Add following HTML into popup.html file:</p><pre>&lt;!doctype html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>  &lt;meta charset=&quot;utf-8&quot;&gt;<br>  &lt;meta http-equiv=&quot;Cache-Control&quot; content=&quot;IE=edge&quot;&gt;<br>  &lt;meta http-equiv=&quot;Pragma&quot; content=&quot;no-cache&quot;&gt;<br>  &lt;meta http-equiv=&quot;Expires&quot; content=&quot;Sat, 01 Jan 2000 00:00:00 GMT&quot;&gt;<br>  &lt;title&gt;RingCentral Embeddable&lt;/title&gt;<br>  &lt;meta name=&quot;description&quot; content=&quot;RingCentral Embeddable&quot;&gt;<br>  &lt;meta<br>    name=&quot;viewport&quot;<br>    content=&quot;width=device-width, initial-scale=1, user-scalable=0, maximum-scale=1, minimum-scale=1&quot;<br>  &gt;<br>  &lt;style&gt;<br>    html {<br>      margin: 0;<br>      padding: 0;<br>      width: 100%;<br>      height: 100%;<br>    }<br>    body {<br>      margin: 0;<br>      padding: 0;<br>      width: 100%;<br>      height: 100%;<br>      overflow: hidden;<br>    }<br>    #appLoading {<br>      text-align: center;<br>      padding-top: 30px;<br>    }<br>    .Adapter_root {<br>      left: 0!important;<br>      top: 0!important;<br>    }<br>    .Adapter_root .Adapter_header {<br>      cursor: default;<br>    }<br>    .Adapter_header .Adapter_button {<br>      display: none;<br>    }<br>  &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>  &lt;div id=&#39;viewport&#39;&gt;<br>    &lt;p id=&quot;appLoading&quot;&gt;<br>      Loading...<br>    &lt;/p&gt;<br>  &lt;/div&gt;<br>  &lt;script src=&quot;./popup.js&quot;&gt;&lt;/script&gt;<br>  &lt;script src=&quot;./embeddable/adapter.js&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Then add the following javascript into popup.js :</p><pre>// popup.js<br>window.__ON_RC_POPUP_WINDOW = 1;</pre><h4>Use service worker for opening a popup window</h4><p>In manifest V2, we use background script to handle app open events. And now we use service worker:</p><pre>// background.js<br>const apiConfig = {<br>  clientId: &#39;your_ringcentral_app_client_id&#39;,<br>  server: &#39;https://platform.devtest.ringcentral.com&#39;,<br>  redirectUri: &#39;https://ringcentral.github.io/ringcentral-embeddable/redirect.html&#39;,<br>};<br>async function openPopupWindow() {<br>  console.log(&#39;open popup&#39;);<br>  const { popupWindowId } = await chrome.storage.local.get(&#39;popupWindowId&#39;);<br>  if (popupWindowId) {<br>    try {<br>      await chrome.windows.update(popupWindowId, { focused: true });<br>      return;<br>    } catch (e) {<br>      // ignore<br>    }<br>  }<br>  // const redirectUri = chrome.identity.getRedirectURL(&#39;redirect.html&#39;); //  set this when oauth with chrome.identity.launchWebAuthFlow<br>  const redirectUri = apiConfig.redirectUri;<br>  let popupUri = `popup.html?multipleTabsSupport=1&amp;disableLoginPopup=1&amp;appServer=${apiConfig.server}&amp;redirectUri=${redirectUri}`;<br>  if (apiConfig.clientId.length &gt; 0) {<br>    popupUri = `${popupUri}&amp;clientId=${apiConfig.clientId}`;<br>  }<br>  const popup = await chrome.windows.create({<br>    url: popupUri,<br>    type: &#39;popup&#39;,<br>    width: 300,<br>    height: 566,<br>  });<br>  await chrome.storage.local.set({<br>    popupWindowId: popup.id,<br>  });<br>}<br><br>chrome.action.onClicked.addListener(function (tab) {<br>  openPopupWindow();<br>});<br><br>chrome.windows.onRemoved.addListener(async (windowId) =&gt; {<br>  const { popupWindowId } = await chrome.storage.local.get(&#39;popupWindowId&#39;);<br>  if (popupWindowId === windowId) {<br>    console.log(&#39;close popup&#39;);<br>    await chrome.storage.local.remove(&#39;popupWindowId&#39;);<br>  }<br>});</pre><p>We use storage to save popupWindowId , so it will not be lost after the service worker becomes inactive.</p><p>Go to “chrome://extensions/”, then reload the extension. We can see the app when the user clicks the extension icon in the browser extensions list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BOo7eDWpKBz-E_e28xpqtw.png" /><figcaption>RingCentral Embeddable extension demo — popup</figcaption></figure><h4>Handle RingCentral authorization</h4><p>We need to handle RingCentral authorization as the default login popup as RingCentral Embeddable default authorization can’t work with manifest V3.</p><pre>// In popup.js<br>function responseMessage(request, response) {<br>  document.querySelector(&quot;#rc-widget-adapter-frame&quot;).contentWindow.postMessage({<br>    type: &#39;rc-post-message-response&#39;,<br>    responseId: request.requestId,<br>    response,<br>  }, &#39;*&#39;);<br>}<br><br>// Interact with RingCentral Embeddable Voice:<br>window.addEventListener(&#39;message&#39;, (e) =&gt; {<br>  const data = e.data;<br>  if (data) {<br>    switch (data.type) {<br>      case &#39;rc-login-popup-notify&#39;:<br>        handleOAuthWindow(data.oAuthUri);<br>        break;<br>      default:<br>        break;<br>    }<br>  }<br>});<br><br>chrome.runtime.onMessage.addListener((request, sender, sendResponse) =&gt; {<br>  if (request.type === &#39;oauthCallBack&#39;) {<br>    document.querySelector(&quot;#rc-widget-adapter-frame&quot;).contentWindow.postMessage({<br>      type: &#39;rc-adapter-authorization-code&#39;,<br>      callbackUri: request.callbackUri,<br>    }, &#39;*&#39;);<br>    sendResponse({ result: &#39;ok&#39; });<br>  }<br>});<br><br>async function handleOAuthWindow(oAuthUri) {<br>  chrome.runtime.sendMessage({<br>    type: &#39;openOAuthWindow&#39;,<br>    oAuthUri,<br>  });<br>  // // Authorize with chrome identify API. Require to have a fixed chrome extension id.<br>  // chrome.identity.launchWebAuthFlow(<br>  //   {<br>  //     url: oAuthUri,<br>  //     interactive: true,<br>  //   },<br>  //   (responseUrl) =&gt; {<br>  //     if (responseUrl) {<br>  //       document.querySelector(&quot;#rc-widget-adapter-frame&quot;).contentWindow.postMessage({<br>  //         type: &#39;rc-adapter-authorization-code&#39;,<br>  //         callbackUri: responseUrl,<br>  //       }, &#39;*&#39;);<br>  //     }<br>  //   },<br>  // );<br>}</pre><pre>// background.js<br>chrome.alarms.onAlarm.addListener(async () =&gt; {<br>  const { loginWindowId } = await chrome.storage.local.get(&#39;loginWindowId&#39;);<br>  if (!loginWindowId) {<br>    return;<br>  }<br>  const tabs = await chrome.tabs.query({ windowId: loginWindowId });<br>  if (tabs.length === 0) {<br>    return;<br>  }<br>  const loginWindowUrl = tabs[0].url<br>  console.log(&#39;loginWindowUrl&#39;, loginWindowUrl);<br>  if (loginWindowUrl.indexOf(apiConfig.redirectUri) !== 0) {<br>    chrome.alarms.create(&#39;oauthCheck&#39;,  { when: Date.now() + 3000 });<br>    return;<br>  }<br>  console.log(&#39;login success&#39;, loginWindowUrl);<br>  chrome.runtime.sendMessage({<br>    type: &#39;oauthCallBack&#39;,<br>    callbackUri: loginWindowUrl,<br>  });<br>  await chrome.windows.remove(loginWindowId);<br>  await chrome.storage.local.remove(&#39;loginWindowId&#39;);<br>});<br><br>chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) =&gt; {<br>  if (request.type === &#39;openOAuthWindow&#39;) {<br>    const loginWindow = await chrome.windows.create({<br>      url: request.oAuthUri,<br>      type: &#39;popup&#39;,<br>      width: 600,<br>      height: 600,<br>    });<br>    await chrome.storage.local.set({<br>      loginWindowId: loginWindow.id,<br>    });<br>    chrome.alarms.create(&#39;oauthCheck&#39;,  { when: Date.now() + 3000 });<br>    sendResponse({ result: &#39;ok&#39; });<br>    return;<br>  }<br>});</pre><p>We can also use the chrome.identify API to set up the RingCentral authorization flow. But the API’s redirect URI is related to Chrome extension id. The Chrome extension id is random and changeable for unpacked and not uploaded to the Chrome extension store.</p><h4>Integrate with third party service</h4><p>Now we have RingCentral features from the embeddable widget. And we can use content scripts to integrate RingCentral with third party services.</p><p>Here we integrate RingCentral Click To Dial feature into Google contacts:</p><pre>// content.js<br>window.clickToDialInject = new window.RingCentralC2D();<br>window.clickToDialInject.on(<br>  window.RingCentralC2D.events.call,<br>  function(phoneNumber) {<br>    console.log(&#39;Click To Dial:&#39;, phoneNumber);<br>    // alert(&#39;Click To Dial:&#39; + phoneNumber);<br>    chrome.runtime.sendMessage({<br>      type: &#39;c2d&#39;,<br>      phoneNumber,<br>    });<br>  },<br>);<br>window.clickToDialInject.on(<br>  window.RingCentralC2D.events.text,<br>  function(phoneNumber) {<br>    console.log(&#39;Click To SMS:&#39;, phoneNumber);<br>    // alert(&#39;Click To SMS:&#39; + phoneNumber);<br>    chrome.runtime.sendMessage({<br>      type: &#39;c2sms&#39;,<br>      phoneNumber,<br>    });<br>  },<br>);</pre><pre>// background.js<br>chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) =&gt; {<br>  if (request.type === &#39;c2d&#39; || request.type === &#39;c2sms&#39;) {<br>    openPopupWindow();<br>  }<br>});</pre><pre>// popup.js<br>chrome.runtime.onMessage.addListener((request, sender, sendResponse) =&gt; {<br>  if (request.type === &#39;oauthCallBack&#39;) {<br>    document.querySelector(&quot;#rc-widget-adapter-frame&quot;).contentWindow.postMessage({<br>      type: &#39;rc-adapter-authorization-code&#39;,<br>      callbackUri: request.callbackUri,<br>    }, &#39;*&#39;);<br>    sendResponse({ result: &#39;ok&#39; });<br>  } else if (request.type === &#39;c2sms&#39;) {<br>    document.querySelector(&quot;#rc-widget-adapter-frame&quot;).contentWindow.postMessage({<br>      type: &#39;rc-adapter-new-sms&#39;,<br>      phoneNumber: request.phoneNumber,<br>    }, &#39;*&#39;);<br>    sendResponse({ result: &#39;ok&#39; });<br>  } else if (request.type === &#39;c2d&#39;) {<br>    document.querySelector(&quot;#rc-widget-adapter-frame&quot;).contentWindow.postMessage({<br>      type: &#39;rc-adapter-new-call&#39;,<br>      phoneNumber: request.phoneNumber,<br>      toCall: true,<br>    }, &#39;*&#39;);<br>    sendResponse({ result: &#39;ok&#39; });<br>  }<br>});</pre><p>After the code, when a user hovers on a web page’s phone number and clicks the dial button, the extension will open the previous app window:</p><h4>Interact with RingCentral Embeddable</h4><p>RingCentral Embeddable provides a lot of <a href="https://github.com/ringcentral/ringcentral-embeddable#documents">API</a> to get data or control the widget. We can interact with it withinpopup.js .</p><pre>// in popup.js:<br>// Get event data from RingCentral Embeddable<br>window.addEventListener(&#39;message&#39;, (e) =&gt; {<br>  const data = e.data;<br>  if (data) {<br>    switch (data.type) {<br>      case &#39;rc-call-ring-notify&#39;:<br>        // get call on ring event<br>        console.log(&#39;RingCentral Embeddable Extension:&#39;, data.call);<br>        break;<br>      case &#39;rc-call-end-notify&#39;:<br>        // get call on call end event<br>        console.log(&#39;RingCentral Embeddable Extension:&#39;, data.call);<br>        break;<br>      case &#39;rc-call-start-notify&#39;:<br>        // get call on start a outbound call event<br>        console.log(&#39;RingCentral Embeddable Extension:&#39;, data.call);<br>        break;<br>      default:<br>        break;<br>    }<br>  }<br>});</pre><pre>function registerService() {<br>  document.querySelector(&quot;#rc-widget-adapter-frame&quot;).contentWindow.postMessage({<br>    type: &#39;rc-adapter-register-third-party-service&#39;,<br>    service: {<br>      name: &#39;TestService&#39;,<br>    }<br>  }, &#39;*&#39;);<br>}<br><br>var registered = false;<br>window.addEventListener(&#39;message&#39;, function (e) {<br>  const data = e.data;<br>  if (data &amp;&amp; data.type === &#39;rc-adapter-pushAdapterState&#39; &amp;&amp; registered === false) {<br>    registered = true;<br>    registerService();<br>  }<br>});</pre><p>For more integration possibilities with RingCentral Embeddable, please refer to the following <a href="https://github.com/ringcentral/ringcentral-embeddable#documents">document</a>.</p><h3>Conclusion</h3><p>Building a Chrome extension using Manifest V3 and integrating RingCentral Embeddable opens up exciting possibilities for enhancing communication within Chrome, Edge or Firefox browser. By following this guide, you will be able to create a feature-rich extension that leverages modern extension architecture and empowers users with seamless communication capabilities.</p><p>You can get the full extension code <a href="https://github.com/embbnux/ringcentral-embeddable-extension/tree/chrome-extension-v3">here</a>. Follow its README document guide to install the extension and try it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0ace34946c3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ringcentral-developers/building-chrome-extension-manifest-v3-with-ringcentral-embeddable-f0ace34946c3">Building Chrome Extension (Manifest V3) with RingCentral Embeddable</a> was originally published in <a href="https://medium.com/ringcentral-developers">RingCentral Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a HTTP Tunnel with WebSocket and Node.JS]]></title>
            <link>https://medium.com/@embbnux/building-a-http-tunnel-with-websocket-and-node-js-98068b0225d3?source=rss-deab83a07f35------2</link>
            <guid isPermaLink="false">https://medium.com/p/98068b0225d3</guid>
            <category><![CDATA[tunnel]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[public-url]]></category>
            <category><![CDATA[socketio]]></category>
            <category><![CDATA[websocket]]></category>
            <dc:creator><![CDATA[Embbnux Ji]]></dc:creator>
            <pubDate>Thu, 03 Mar 2022 15:47:09 GMT</pubDate>
            <atom:updated>2023-07-10T04:16:28.352Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lX-ussvVzU2HE5mPWJZtOg.png" /></figure><p>When we develop some apps or bots which integrate with third party service, we need to make our local development server to be exposed into Internet to get Webhook message. To do that, we need HTTP tunnel for our local server. How does HTTP tunnel work? In this article, I will show you how I build a HTTP tunnel tool based on WebSocket and Node.js stream, learn how to use Node.js stream to transfer big data.</p><h3>Why we need to deploy our own HTTP tunnel service</h3><p>There are lots of awesome online services for HTTP tunnel. For example, we can use ngrok to get paid fixed public domain to connect your local server. It also has free package. But for free package, you can’t get a fixed domain. Once you restart the client, you will get a new random domain. It is inconvenient when you need to save the domain in third party service.</p><p>To get a fix domain, we can deploy HTTP tunnel in our own server. ngrok also provides an <a href="https://github.com/inconshreveable/ngrok">open source version</a> for server side deployment. But it is old 1.x version and not recommended to deploy at production with some serious reliability issues.</p><p>With our own server, it can also keep data security.</p><h3>Introduction about Lite HTTP Tunnel</h3><p><a href="https://github.com/web-tunnel/lite-http-tunnel">Lite HTTP Tunnel</a> is what I build recently for self-host HTTP tunnel service. You can deploy it with Heroku button in the Github repository to get a free fixed Heroku domain quickly.</p><p>It is built based on Express.js and Socket.io with just few code. It uses WebSocket to stream HTTP/HTTPS request from public server into your local server.</p><h3>How I implement it</h3><h4>Step 1: build a WebSocket connection between server and client</h4><p>Support WebSocket connection at server side with socket.io:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba01f04924f442086ee9a8de5259a8a9/href">https://medium.com/media/ba01f04924f442086ee9a8de5259a8a9/href</a></iframe><p>Connect WebSocket at Client side:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4e72f450057bda68a05db96d0a06915/href">https://medium.com/media/c4e72f450057bda68a05db96d0a06915/href</a></iframe><h4>Step2: Use JWT token to protect WebSocket Connection</h4><p>In server side, we use socket.io middleware to reject invalid connection:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/caa1cda704aa3494ba5ed1ae0f3a608d/href">https://medium.com/media/caa1cda704aa3494ba5ed1ae0f3a608d/href</a></iframe><h4>Step 3: Data Stream Transmission</h4><p>In Node.js, both HTTP Request and Response are streams. On the server side, Request is a Readable stream, while Response is a Writable stream.<br>The normal data stream transmission in a node.js web server is shown in the following diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*EnYIXKAhtRbpNcIa.png" /><figcaption>Normal Node.js Web Server</figcaption></figure><p>And now that our Web Server is inside the local firewall, we use a public server to forward the Request and Response through. Therefore, the user’s HTTP data first goes to the Tunnel server, which sends the Request to the Tunnel client, and then the Tunnel client sends the Request to the Local web server to get the Response, which is finally returned to the Tunnel server for transmission to the Client side.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*942S6aRiZXsriAjG.png" /><figcaption>Client to Tunnel Server</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*xKj0hWVjb1k8PnVC.png" /><figcaption>Tunnel Server to Tunnel client</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*da8r3YsCSLOrZlQb.png" /><figcaption>Tunnel Client to Local Server</figcaption></figure><p>To transmit the Request and Response streams between the Tunnel server and Tunnel client, we implement a TunnelRequest writable stream class and TunnelResponse readable stream class on the Tunnel server side, based on WebSocket, and a TunnelRequest readable stream class and TunnelResponse writable stream class on the Tunnel client side.</p><p>Tunnel server side：</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d15c04c9af735dea185c89389417fd54/href">https://medium.com/media/d15c04c9af735dea185c89389417fd54/href</a></iframe><p>Tunel client side:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3ee146dc800e3258c51bb6b47336e92/href">https://medium.com/media/b3ee146dc800e3258c51bb6b47336e92/href</a></iframe><p>To learn more about Node.js stream, you can refer to the official <a href="https://nodejs.org/api/stream.html">documentation</a>. For the implementation of TunnelRequest and TunnelResponse, you can visit <a href="https://github.com/web-tunnel/lite-http-tunnel/blob/main/lib.js">https://github.com/web-tunnel/lite-http-tunnel/blob/main/lib.js</a>.</p><p>After completing all of the above steps, we now support streaming HTTP requests to a local computer and sending responses from the local server back to the original request. This is a lightweight solution, but it is highly stable and easy to deploy in any Node.js environment.</p><h3>Step 4: Deploy HTTP Tunnel service</h3><p>We can deploy the HTTP tunnel service to a cloud provider such as Heroku/Render. The project <a href="https://github.com/web-tunnel/lite-http-tunnel">Lite HTTP Tunnel</a> contains a Heroku/Render button in the Github repository, which allows you to deploy the service to Heroku/Render quickly.</p><h3>More</h3><p>So we have introduced about how to transfer HTTP requests based on WebSocket and Node.js <strong>Writable </strong>and <strong>Readable </strong>stream. In latest version of Lite HTTP Tunnel, we refactor the project with <strong>Duplex</strong> stream to support requests from WebSocket. You can check that from <a href="https://github.com/web-tunnel/lite-http-tunnel">source code</a>.</p><p>If you just want to find a HTTP tunnel service with a free fixed domain, you can try to deploy <a href="https://github.com/web-tunnel/lite-http-tunnel">Lite HTTP Tunnel</a> project with deploy button in the <a href="https://github.com/web-tunnel/lite-http-tunnel#deploy-at-public-server">Github README</a>. Hope you can learn something from this article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98068b0225d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Run RingCentral Phone on Raspberry Pi]]></title>
            <link>https://medium.com/ringcentral-developers/run-ringcentral-phone-on-raspberry-pi-59b7aeafb262?source=rss-deab83a07f35------2</link>
            <guid isPermaLink="false">https://medium.com/p/59b7aeafb262</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[electron]]></category>
            <category><![CDATA[ringcentral]]></category>
            <dc:creator><![CDATA[Embbnux Ji]]></dc:creator>
            <pubDate>Thu, 18 Nov 2021 19:52:35 GMT</pubDate>
            <atom:updated>2021-11-18T19:52:35.755Z</atom:updated>
            <content:encoded><![CDATA[<p>Raspberry Pi is a small single board computer, it can act as a cheap mini personal computer, or as a control center of IoT devices. In this article, I will introduce how to run the RingCentral phone service inside Raspberry Pi, so we can connect Raspberry Pi with Cloud Communications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MY1fvIKOS_6eeI0LsfzdlQ.png" /><figcaption>RingCentral Embeddable in Raspberry Pi</figcaption></figure><p>In the previous article, we introduce <a href="https://medium.com/ringcentral-developers/building-a-desktop-app-with-ringcentral-embeddable-and-electron-5e53943732a">how to build a desktop app with RingCentral Embeddable and Electron</a>. Since it works for Linux, so we can also make it work with Raspberry Pi. Raspberry Pi’s default OS <strong>Raspberry Pi OS</strong> is based on Debian (a Linux distribution). But we need to rebuild the app with the ARMv7 platform. When we build the electron app in our local computer, it builds for i386 or amd64 platform by default.</p><h3>Build for ARMv7</h3><p>First we clone the project and install dependencies:</p><pre>$ git clone https://github.com/ringcentral/ringcentral-embeddable-electron-app.git<br>$ cd ringcentral-embeddable-electron-app<br>$ yarn</pre><p>Then we will build for the ARMv7</p><pre>$ yarn package --dir --armv7l --linux deb</pre><p>After building, we can get deb package for ARMv7 in the release folder.</p><p>Copy the package and install in Raspberry Pi. Then we can get the app from the Start Menu.</p><p>You can get the precompiled package <a href="https://github.com/ringcentral/ringcentral-embeddable-electron-app/releases/tag/v0.1.5">here</a>. It is recommended to use it with Raspberry Pi 3B or Raspberry Pi 4B.</p><h3>RingCentral Embeddable with Raspberry Pi</h3><p>Since the app is based on the RingCentral Embeddable and Electron, it allows us to use Electron JS to transfer data between RingCentral Embeddable and Raspberry Pi.</p><p>You can get how to interact with RingCentral Embeddable in electron from this <a href="https://medium.com/ringcentral-developers/building-a-desktop-app-with-ringcentral-embeddable-and-electron-5e53943732a">article </a>, such as incoming call or SMS notifications.</p><p>Electron.js is run on the System. So wen can use Electron.js to call the system API directly.</p><h3>Other solutions</h3><p>In this article, we use Electron and <a href="https://github.com/ringcentral/ringcentral-embeddable">RingCentral Embeddable</a> to run RingCentral services in Raspberry Pi. In this solution, it supports UI and voice transmission.</p><p>If you only need voice transmission such as real time translation service, we can use <a href="https://github.com/ringcentral/ringcentral-softphone-js">RingCentral Softphone JS SDK</a>. It can run on node.js.</p><p>If you don’t need UI and voice transmission, only want to control your RingCentral service and get event notification from RingCentral, we can just build app based on <a href="https://developers.ringcentral.com/api-reference/voice">RingCentral RESTful API</a>. Go <a href="https://developers.ringcentral.com/guide/sdks">here</a> to get official SDKs. Please let us know what you think by leaving your questions and comments below. To learn even more about other features we have make sure to visit our <a href="https://developers.ringcentral.com/api-and-docs.html"><strong>developer site</strong></a><strong> </strong>and if you’re ever stuck make sure to go to our <a href="https://forums.developers.ringcentral.com/index.html"><strong>developer forum</strong></a><strong>.</strong></p><p><em>Want to stay up to date and in the know about new APIs and features? Join our </em><a href="https://gamechanging.dev/"><strong><em>Game Changer Program</em></strong></a><em> and earn great rewards for building your skills and learning more about RingCentral!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59b7aeafb262" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ringcentral-developers/run-ringcentral-phone-on-raspberry-pi-59b7aeafb262">Run RingCentral Phone on Raspberry Pi</a> was originally published in <a href="https://medium.com/ringcentral-developers">RingCentral Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Log RingCentral call information into Google Sheets with Forms]]></title>
            <link>https://medium.com/ringcentral-developers/log-ringcentral-call-information-into-google-sheets-with-forms-630a29c893a4?source=rss-deab83a07f35------2</link>
            <guid isPermaLink="false">https://medium.com/p/630a29c893a4</guid>
            <category><![CDATA[ringcentral]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[google-forms]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[google-sheets]]></category>
            <dc:creator><![CDATA[Embbnux Ji]]></dc:creator>
            <pubDate>Tue, 26 Oct 2021 17:03:25 GMT</pubDate>
            <atom:updated>2021-10-26T17:03:25.112Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ktyMKaYWIcXZLoukAjEJlw.png" /></figure><p>In the RingCentral integration for CRMs, user can get a pre-filled form when user have a call, and save the call information into CRMs. But how do we pre-fill and save the call information into google sheets when a user gets a call?</p><p>The answer is to use Forms with Google Sheets. Google Sheets doesn’t support pre-filling cell data, but Forms can.</p><h3>Step1: Create Forms from a google sheet</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f_6m7IOzLTwZzr2NML7hhQ.png" /></figure><p>Add filed in the form:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vSokqUB1D8mM8a4UMb28ag.png" /></figure><h3>Step 2: Get form pre-fill link</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ayH_hGwYZz2GJSCHqd53VQ.png" /></figure><p>Click Get pre-filled link under more icon.</p><p>In pre-filled form, input variable name:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E3W89NxSRHSl7voY26YjJg.png" /></figure><p>Then click Get link button to get and copy a pre-filled link for user:</p><pre><a href="https://docs.google.com/forms/d/e/1FAIpQLSfM_6j2FrtI5TOkXqER-4HtcAwCWBk9gUikpLcf0tJX7SMO0A/viewform?usp=pp_url&amp;entry.922493126=name&amp;entry.1572515229=phone_number&amp;entry.610677478=called_number">https://docs.google.com/forms/d/e/1FAIpQLSfM_6j2FrtI5TOkXqER-4HtcAwCWBk9gUikpLcf0tJX111111/viewform?usp=pp_url&amp;entry.922493126=name&amp;entry.1572515229=phone_number&amp;entry.610677478=called_number</a></pre><p>Then replace `name` with `%N`, `phone_number` with `%E`, and `called_number` with `%D`:</p><pre><a href="https://docs.google.com/forms/d/e/1FAIpQLSfM_6j2FrtI5TOkXqER-4HtcAwCWBk9gUikpLcf0tJX7SMO0A/viewform?usp=pp_url&amp;entry.922493126=%N&amp;entry.1572515229=%E&amp;entry.610677478=%D">https://docs.google.com/forms/d/e/1FAIpQLSfM_6j2FrtI5TOkXqER-4HtcAwCWBk9gUikpLcf0tJX111111/viewform?usp=pp_url&amp;entry.922493126=%N&amp;entry.1572515229=%E&amp;entry.610677478=%D</a></pre><h3>Step 3: Set the pre-filled link at RingCentral Phone desktop app</h3><p>Install and sign in <a href="https://www.ringcentral.com/apps/rc-phone">RingCentral Phone desktop app</a>.</p><p>At Settings &gt; Calls &gt;Incoming, enable “Launch an external app or a URL on incoming call”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IlWRQt6eSow4-FCT9N9uHw.png" /></figure><p>Save the pre-filled link at Execute command input.</p><p>Now when a user gets an incoming call, the app will open the pre-filled form link with the RingCentral call information pre-filled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xphqhz6bVTwU6h_NTTyjBA.png" /></figure><p>When the user submits, the data will be collected into the google sheet that you created form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u_DAkhaHSDuHdLWg4sFqNA.png" /></figure><h3>More</h3><p>RingCentral Phone app only supports to open URI at incoming calls, and only support some arguments at the URI. To support outgoing calls and more arguments, You can try to build a RingCentral app with <a href="https://github.com/ringcentral/ringcentral-embeddable">RingCentral Embeddable</a>.</p><p>Using RingCentral Embeddable to <a href="https://github.com/ringcentral/ringcentral-embeddable/blob/master/docs/widget-event.md#active-call-event">listen call event</a> and open window with the pre-set URI.</p><p>Please let us know what you think by leaving your questions and comments below. To learn even more about other features we have make sure to visit our <a href="https://developers.ringcentral.com/api-and-docs.html"><strong>developer site</strong></a><strong> </strong>and if you’re ever stuck make sure to go to our <a href="https://forums.developers.ringcentral.com/index.html"><strong>developer forum</strong></a><strong>.</strong></p><p><em>Want to stay up to date and in the know about new APIs and features? Join our </em><a href="https://gamechanging.dev/"><strong><em>Game Changer Program</em></strong></a><em> and earn great rewards for building your skills and learning more about RingCentral!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=630a29c893a4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ringcentral-developers/log-ringcentral-call-information-into-google-sheets-with-forms-630a29c893a4">Log RingCentral call information into Google Sheets with Forms</a> was originally published in <a href="https://medium.com/ringcentral-developers">RingCentral Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ShareService: a library for building multiple tabs react app]]></title>
            <link>https://medium.com/@embbnux/shareservice-a-library-for-building-multiple-tabs-react-app-2b00d04b25fa?source=rss-deab83a07f35------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b00d04b25fa</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[shared-worker]]></category>
            <category><![CDATA[cross-window]]></category>
            <category><![CDATA[multiple-tabs]]></category>
            <category><![CDATA[state-management]]></category>
            <dc:creator><![CDATA[Embbnux Ji]]></dc:creator>
            <pubDate>Sat, 21 Aug 2021 16:58:43 GMT</pubDate>
            <atom:updated>2021-08-21T17:31:24.972Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F9DrqGGgsE2I%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D9DrqGGgsE2I&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F9DrqGGgsE2I%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b3f31dcf6867a8986be5b6840ed93bd/href">https://medium.com/media/4b3f31dcf6867a8986be5b6840ed93bd/href</a></iframe><p>We can use React to create single page apps easily, React helps us to render UI state. But for every new tab, app need to run our business logics and services to have data for react to rendering. So can we centralize our business logics and services?</p><p>`SharedWorker` is the solution. And we have <a href="https://github.com/shared-service/shared-service">`shared-service`</a> library to help you centralize your business logics and services and build a multiple tabs react app without pain.</p><h3>How it work</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EsnZ2hRcmu0OYirBePRdBA.png" /></figure><p>SharedWorker instance will be reused by cross browser tabs with same domain until all pages are closed.</p><ol><li>App creates SharedWorker to load data generate UI state when user open first tab.</li><li>App gets UI state from existing SharedWorker instance when user load second tab.</li><li>App send action to execute in SharedWorker instance when user has action in web page</li><li>SharedWorker instance send UI state to tabs that use it after action executing</li></ol><h3>Work with ShareService library</h3><p>I assume you have start a react app with create-react-app .</p><ol><li>First step: install it</li></ol><pre>$ npm install @shared-service/core @shared-service/react</pre><p>2 .Init shared service in your react app root endpoint:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8339490289765729da359803268997b8/href">https://medium.com/media/8339490289765729da359803268997b8/href</a></iframe><p>3. Connect Shared Service in ShareWorker worker.js file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/245be7741e2108af436c84ef8edf6ba4/href">https://medium.com/media/245be7741e2108af436c84ef8edf6ba4/href</a></iframe><p>4. In react component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3fd451cb804a1ccd933112c3ccadaa51/href">https://medium.com/media/3fd451cb804a1ccd933112c3ccadaa51/href</a></iframe><p>For simple state logic, we can just use setCount function return useSharedState to update it into SharedService.</p><p>For complex actions, we can send it to execute in sharedServiceServer .</p><p>Firstly register executor into sharedServiceServer atworker.js:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4244e5ce75beee2ce6828f5fa8eb7d4/href">https://medium.com/media/c4244e5ce75beee2ce6828f5fa8eb7d4/href</a></iframe><p>Send the action in react component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66b9d31a80b472aea5f7a416d713e21c/href">https://medium.com/media/66b9d31a80b472aea5f7a416d713e21c/href</a></iframe><p>5. Data persistence</p><p>We can persist data in SharedWorker with IndexedDB. Here we use localforage lib to help us handle storage.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34cb1c1ddda499f33848ba177e79e482/href">https://medium.com/media/34cb1c1ddda499f33848ba177e79e482/href</a></iframe><h4>Online demo</h4><p>We have online demo <a href="https://shared-service.github.io/todo-demo/">here</a>. For full demo source code, please refer <a href="https://github.com/shared-service/shared-service/tree/main/packages/demo">here</a>.</p><h4>Problem</h4><p>As SharedWorker is not supported for Safari and IE now, so we can’t run `share-service` at the shared worker for those Browser. You can take a look at <a href="https://github.com/shared-service/shared-service/blob/main/packages/demo/src/index.js#L14">here</a> to make app work at Safari.</p><h3>More</h3><p>There are some TODO for `shared-service` library:</p><ol><li>Add support for `Vue.js` library.</li></ol><p>2. Support Browser extension (with background API)</p><p>3. Support Electron main and render process</p><p>To make Browser extension and Electron app support the centralization service.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b00d04b25fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Linux desktop app for the RingCentral Video web app with Electron.js]]></title>
            <link>https://medium.com/ringcentral-developers/create-a-linux-desktop-app-for-the-ringcentral-video-web-app-with-electron-js-794b9f713dfe?source=rss-deab83a07f35------2</link>
            <guid isPermaLink="false">https://medium.com/p/794b9f713dfe</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[electron]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[ringcentral]]></category>
            <dc:creator><![CDATA[Embbnux Ji]]></dc:creator>
            <pubDate>Tue, 20 Jul 2021 21:44:21 GMT</pubDate>
            <atom:updated>2021-07-20T21:44:21.968Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wAotAp3IXaA8cADz3ORLzg.png" /></figure><p>For most apps, they only provide web apps for Linux based OS, not desktop apps. But web apps are not as convenient as the desktop. So how can we transform a web app into a linux desktop app quickly? In this article, I will show you how to create a linux desktop app for the RingCentral Video web app with Electron.js.</p><h3>Prerequisites</h3><ol><li>RingCentral Video web app: <a href="https://app.ringcentral.com/">https://app.ringcentral.com/</a></li><li><a href="https://www.electronjs.org/">Electron.js</a></li><li>NPM or Yarn (We assume you have installed node.js &gt; 10)</li></ol><h3>Init Electron project</h3><p>Follow <a href="https://www.electronjs.org/docs/tutorial/quick-start">Electron.js quick start</a> to have a blank project:</p><p>Init project:</p><pre>$ yarn init<br>$ yarn add electron --dev</pre><p>Add start script in `package.json`:</p><pre>{<br>  &quot;scripts&quot;: {<br>     &quot;start&quot;: &quot;electron .&quot;<br>   }<br>}</pre><p>And create blank file: main.js and preload.js.</p><p>We will have these three files:</p><pre>electron-app-with-rc-video/<br>├── package.json<br>├── main.js<br>└── preload.js</pre><h3>Load RingCentral Video web app</h3><p>We will create a `BrowserWindow` instance to load RingCentral Video web app:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a3191c91e7538fa9befb72e6e7049a0f/href">https://medium.com/media/a3191c91e7538fa9befb72e6e7049a0f/href</a></iframe><p>We create a session from partition to persist local data in RingCentral Video web app, and setup preload.js into the window, so we can inject some code into the web application.</p><p>Now we can start electron app:</p><pre>$ yarn start</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Bsb1BneAIk2rSFyEUCq5Q.png" /></figure><p>After login, we now have the messages feature working.</p><h3>Show unread message count at dock icon</h3><p>As a desktop app, we can now show the unread messages count on the dock icon.</p><p>First, we use `preload.js` to get the unread count from the page title. Then send the count to the main process.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0bc8375711b539ccf5ed35ac86f82a3c/href">https://medium.com/media/0bc8375711b539ccf5ed35ac86f82a3c/href</a></iframe><p>In the main process the app receives the message and sets the badge:</p><pre>const { ipcMain } = require(&#39;electron&#39;);</pre><pre>ipcMain.on(&#39;show-notifications-count&#39;, (_, count) =&gt; {<br>  app.setBadgeCount(count);<br>});</pre><h3>Open link in default browser</h3><p>Add the following code in `main.js` createMainWindow function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ea6b763d6df8604a81935dc6b373281/href">https://medium.com/media/6ea6b763d6df8604a81935dc6b373281/href</a></iframe><p>With this the app will open link in the message with the system default browser.</p><h3>Customize browser user agent string:</h3><p>In the RingCentral Video web app, it checks the User-Agent string, and has some special behaviors when there is anElectron string at the User-Agent. But it makes our apps’ meeting feature break.</p><p>So we need to customize the User-Agent.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0503d34d2fe2852f22b99cd74cbee7e/href">https://medium.com/media/d0503d34d2fe2852f22b99cd74cbee7e/href</a></iframe><p>So now we can have the video meeting feature working in the app as well:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j13tlcQIfP1RN969ktUEKQ.png" /></figure><h3>Support screen sharing</h3><p>Electron doesn’t implement `navigator.mediaDevices.getDisplayMedia` as Chrome. So we need to implement it — some instructions are <a href="https://github.com/electron/electron/issues/16513#issuecomment-602070250">here</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3f88b4d7f249741bbcff843ecb651909/href">https://medium.com/media/3f88b4d7f249741bbcff843ecb651909/href</a></iframe><p>So now we can have the screen sharing feature at meetings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6h3EPioCt2a4_ergQZOSjw.png" /></figure><h3>Package app with electron builder</h3><p>After development, we need to package this app, so users can install it easily.</p><p>We use electron-builder to package it:</p><pre>$ yarn add electron-builder --dev</pre><p>Create `electron-builder.yml`:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2027695b9ac21e38e7b87e0bd48b9884/href">https://medium.com/media/2027695b9ac21e38e7b87e0bd48b9884/href</a></iframe><p>Add scripts command into `package.json`:</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;electron .&quot;,<br>    &quot;package-linux&quot;: &quot;electron-builder --linux&quot;<br>  },<br>}</pre><p>To package for a linux platform:</p><pre>$ yarn package-linux</pre><h3>More Information</h3><p>You can get the full source code <a href="https://github.com/embbnux/ringcentral-community-app">here</a>. I have also packaged this app for Linux users, you can go <a href="https://github.com/embbnux/ringcentral-community-app/releases">here</a> to download and try it out. Please let us know what you think by leaving your questions and comments below. To learn even more about other features we have make sure to visit our <a href="https://developers.ringcentral.com/api-and-docs.html"><strong>developer site</strong></a><strong> </strong>and if you’re ever stuck make sure to go to our <a href="https://forums.developers.ringcentral.com/index.html"><strong>developer forum</strong></a><strong>.</strong></p><p><em>Want to stay up to date and in the know about new APIs and features? Join our </em><a href="https://gamechanging.dev/"><strong><em>Game Changer Program</em></strong></a><em> and earn great rewards for building your skills and learning more about RingCentral!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=794b9f713dfe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ringcentral-developers/create-a-linux-desktop-app-for-the-ringcentral-video-web-app-with-electron-js-794b9f713dfe">Create a Linux desktop app for the RingCentral Video web app with Electron.js</a> was originally published in <a href="https://medium.com/ringcentral-developers">RingCentral Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connect RingCentral API in Engage Voice IVR Studio]]></title>
            <link>https://medium.com/ringcentral-developers/connect-ringcentral-api-in-engage-voice-ivr-studio-7af3ae236445?source=rss-deab83a07f35------2</link>
            <guid isPermaLink="false">https://medium.com/p/7af3ae236445</guid>
            <category><![CDATA[enage-voice]]></category>
            <category><![CDATA[ivr-studio]]></category>
            <category><![CDATA[ringcentral]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Embbnux Ji]]></dc:creator>
            <pubDate>Thu, 04 Feb 2021 16:24:30 GMT</pubDate>
            <atom:updated>2021-12-08T09:31:50.533Z</atom:updated>
            <content:encoded><![CDATA[<h3>Connect the RingCentral API in the Engage Voice IVR Studio</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y0j4c5t_7u5L-DVoHaoEXw.png" /></figure><p>The RingCentral Engage Voice IVR Studio is a drag-and-drop interface that helps customers to build a visual representation of IVR actions. With the IVR Studio, an admin can create IVR logics without coding. So how do you connect a third party API to the Engage Voice IVR Studio. In this article, we will show you how to Connect the RingCentral API in IVR Studio.</p><h3>Prerequisites</h3><ol><li>Basic knowledge about <a href="https://support.ringcentral.com/engagevoice/admin/voice-admin-intro-ivr-designer.html">Engage Voice IVR designer</a></li><li>A free <a href="https://developer.ringcentral.com/">RingCentral Developer</a> account to create a RingCentral app (type : private)</li></ol><h3>Step 1: Create IVR</h3><p>Create a IVR by following this <a href="https://support.ringcentral.com/engagevoice/admin/voice-admin-create-ivr.html">document</a>. We also need to assign a number, so we can test it.</p><p>After the IVR is created, we can see a IVR studio option:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WWIO6i-s9iIcGNcs2FKaVg.png" /></figure><h3>Step 2: IVR Studio</h3><p>There are lots of nodes at the left bar of the IVR Studio. We can just drag them into the background, and by doing a long click we can drag at the plus icon to connect the nodes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EbYx1et1MAIIbNLiZtw_hw.png" /></figure><h3>Step 3: Authorization RingCentral API</h3><p>We will use <a href="https://support.ringcentral.com/engagevoice/admin/voice-admin-use-www-node.html">WWW</a> node to send the authorization request to the RingCentral API. Drag a www node into the background, and double click to the edit the properties:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Asz1uNLW9fiSbJIKTJAuA.png" /></figure><p>Since we don’t have a UI to authorize — we will need to use the password grant type (we need to select private app when creating the RingCentral app).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*izcB1lzneyfzgYiKUQ4LCg.png" /></figure><p>We also need to set HTTP Headers as required by the <a href="https://developers.ringcentral.com/api-reference/Get-Token">RingCentral auth API</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1yonx9ajDuSSP8kyRJmW0g.png" /></figure><p>The value of the Authorization header is base64 encoded value of your_rincentral_app_client_id:your_ringcentral_app_secret_id</p><p>Step 3: Save access token</p><p>After we get an authorization response from the WWW node, we need to save it.</p><p>Drag a <a href="https://support.ringcentral.com/engagevoice/admin/voice-admin-use-scripting-node.html">Scripting</a> node and connect it after the WWW node, then double click to edit it.</p><p>Add the following code into the Scripting node:</p><pre>var data = ivr.getData(&#39;AuthorizationRC&#39;);<br>var authResponseData = JSON.parse(data);<br>var responseBody = JSON.parse(authResponseData.response_body);<br>ivr.putData(&#39;$rcAccessToken&#39;, responseBody.access_token);</pre><pre>var rcAuthorization = responseBody.token_type + &#39; &#39; + responseBody.access_token;<br>ivr.putData(&#39;$rcAuthorization&#39;, rcAuthorization);</pre><p>We save the access token into the $rcAccessToken key, and an authorization header into the $rcAuthorization key.</p><h3>Step 4: send SMS by RingCentral API</h3><p>We need another WWW node to send the SMS request. Just drag a new node, and edit it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qXhqiKFnHAGOMglwGXrz2A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ubrvaooq0xYYIux-yj-aCA.png" /></figure><p>We also need to set the authorization header, this is different with the Authorization API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sEF7o2xnJyVUoBgmsySNMw.png" /></figure><p>We read the authorization value from the$rcAuthorization that we set in the upper node.</p><h3>Step 5: Revoke token</h3><p>After we finish the API request, we need to revoke token. Just drag a WWW node after the request node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5hTCgq55OMmjcEXadQzkNg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xi4pbZxXdYzJ6I8yrszH-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AXG_vImS4hSGuyn-CUhbrQ.png" /></figure><p>The Authorization value will be the same as what we did in the authorization node.</p><h3><strong>Step 6: Router</strong></h3><p>After we finish all the requests, we need to route the call to some number or call queue.</p><p>Drag a Router node at the end:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*BMKLTCEEZ5lz51iFTBNYSg.png" /></figure><p>So after we have finished all the nodes, they should be connected as pictured below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IeJbUkl_1Rkj9IxbB5cy2w.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FlAAOUnva6YY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DlAAOUnva6YY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FlAAOUnva6YY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/154422ccdc5cff062b5710c52a90fccd/href">https://medium.com/media/154422ccdc5cff062b5710c52a90fccd/href</a></iframe><h3>Conclusion</h3><p>In this article, we introduced how to authorize and request the RingCentral API with the Engage Voice IVR Studio. You can also use it as an example when you request third party APIs in the Engage Voice IVR Studio. Hopefully this article was helpful.</p><p>Please let us know what you think by leaving your questions and comments below. To learn even more about other features we have make sure to visit our <a href="https://developers.ringcentral.com/api-and-docs.html"><strong>developer site</strong></a><strong> </strong>and if you’re ever stuck make sure to go to our <a href="https://forums.developers.ringcentral.com/index.html"><strong>developer forum</strong></a><strong>.</strong></p><p><em>Want to stay up to date and in the know about new APIs and features? Join our </em><a href="https://gamechanging.dev/"><strong><em>Game Changer Program</em></strong></a><em> and earn great rewards for building your skills and learning more about RingCentral!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7af3ae236445" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ringcentral-developers/connect-ringcentral-api-in-engage-voice-ivr-studio-7af3ae236445">Connect RingCentral API in Engage Voice IVR Studio</a> was originally published in <a href="https://medium.com/ringcentral-developers">RingCentral Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use Authorization Code + PKCE for RingCentral API in Client App]]></title>
            <link>https://medium.com/ringcentral-developers/use-authorization-code-pkce-for-ringcentral-api-in-client-app-e9108f04b5f0?source=rss-deab83a07f35------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9108f04b5f0</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Embbnux Ji]]></dc:creator>
            <pubDate>Thu, 06 Aug 2020 18:02:48 GMT</pubDate>
            <atom:updated>2021-03-09T09:17:55.785Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7DDEcm_Oh0huoJ_Xx9KJ8w.png" /></figure><p>RingCentral APIs use OAuth 2.0 for authorization. But which grant flow is the best practice for client side apps, such as desktop, mobile app and web (Single Page Apps)? The answer to that is authorization code with Proof Key for Code Exchange. In this article, I will introduce and show you how to implement authorization code with PKCE flow in Single Page Apps.</p><h3>Useful Links</h3><ol><li>RingCentral APIs reference: <a href="https://developers.ringcentral.com/api-reference/authentication">Authorization in RingCentral API</a>s</li><li>IETF link: <a href="https://tools.ietf.org/html/rfc7636">Proof Key for Code Exchange by OAuth Public Clients</a></li></ol><h3>Authorization code and Implicit grant flow</h3><h4>Authorization code grant flow:</h4><p>We can get full steps of authorization code grant flow in following diagram. A Third party app will need the RingCentral client id and client secret to exchange and refresh the access token. Third party app will stay authorized if it refreshes the RingCentral access token before the refresh token has expired, and will get a new refresh token and access token when it refreshes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E4emusJ7h2G246_I4uwy2w.png" /><figcaption>authorization code flow of RingCentral</figcaption></figure><h4>Implicit grant flow</h4><p>We can see the full steps of the implicit grant flow in the following diagram. It is designed for client-side app. Third party app only need client id. The login server will return access token to browser directly. Third party app can’t refresh access token. To get new token, user need to visit login server again. We can use a hidden iframe to implement token refreshing flow. The login server use Browser session to remember user login status. The Browser session will be expired in half hour. So if third party app don’t refresh in half hour, third party app will be unauthorized after access token expired.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bgzWLMBIoidHkyuksP8oRw.png" /><figcaption>Implicit grant flow of RingCentral APIs</figcaption></figure><h3>Why we need Authorization Code with PKCE</h3><p>In a client-side app such as Single Page Apps — the app will need to implement auth flow on the client side without server. Therefore, authorization code grant flow is not a suitable option for a client-side app, because we need to store app client id and secret on the client side. It is not safe to restore client secret on the client side.</p><p>The implicit grant flow is designed for a client-side app. But in the implicit grant flow, a user will be unauthorized if the user closes the app for more than a half hour. The implicit grant flow returns the access token in the redirect URI. So the access token is exposed in the Browser history which may cause security issues.</p><p>Authorization code with PKCE grant flow is a new solution for a client-side app. It is a security enhancement for the authorization code flow. The third party app will only need the client id. But when the user starts the authorization, it will generate a cryptographically-random string code_verifier. And encrypt the code_verifier into the code_challenge. The app will pass the code_challenge into the RingCentral login web page. In the code exchanging step, the app will use the authorization code and the code_verifier to exchange the access token and refresh token. The RingCentral API server will encode the code_verifier and verify it with the code_challenge that passed previously. The code_verifier will be changed for every authorization request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K0ZwF5xKKUj2tqXyhbhlKQ.png" /><figcaption>authorization code with PKCE of RingCentral APIs</figcaption></figure><p>Compared to the authorization code flow, it doesn’t store the app secret on the app side, so it can work with a client-side app. And compared to an implicit grant flow, it can refresh the access token by refresh_token. The authorization code is exposed in the Browser history, but the code can’t be used without the code_verifier .</p><h3>Implement Authorization Code with PKCE flow with RingCentral JS SDK</h3><p>We have implemented the Authorization code with the PKCE flow in the <a href="https://github.com/ringcentral/ringcentral-js/tree/master/sdk#login">RingCentral JS SDK v4</a>.</p><p>To use the PKCE flow, just pass the usePKCE into the `loginUrl` function, and everything will be the same as the authorization code or implicit flow:</p><pre>var rcsdk = new RingCentral.SDK({<br>    server: RingCentral.SDK.server.production,<br>    clientId: &#39;yourClientId&#39;,<br>    redirectUri: &#39;yourRedirectURI&#39;<br>});<br>// generate login url with PKCE<br>var loginUrl = rcsdk.loginUrl({ usePKCE: true }); <br>rcsdk.loginWindow({url: loginUrl}) // will popup login window<br>    .then(function (loginOptions){<br>        return rcsdk.login(loginOptions);<br>    })<br>    .then(...)<br>    .catch(...);</pre><p>The SDK will help generate the code_verifier and the code_challenge, and also will pass them to the RingCentral server.</p><p>You can get the demo code <a href="https://github.com/ringcentral/ringcentral-js/tree/master/demo">here</a>.</p><h4>How we implement PKCE from authorization code flow:</h4><p>Firstly, we need to generate code_verifier. The code_verifier is just a random string:</p><pre>import {randomBytes, createHash} from &#39;crypto&#39;;</pre><pre>function _generateCodeVerifier() {<br> let codeVerifier: any = randomBytes(32);<br>    codeVerifier = codeVerifier<br>        .toString(&#39;base64&#39;)<br>        .replace(/\+/g, &#39;-&#39;)<br>        .replace(/\//g, &#39;_&#39;)<br>        .replace(/=/g, &#39;&#39;);<br>    return codeVerifier;<br>}</pre><p>We need to make sure the string don’t include “+”, “/” and “=”.</p><p>code_challenge is `sha256` encoded value from code_verifier :</p><pre>this._codeVerifier = &#39;&#39;;<br>if (usePKCE) {<br>    this._codeVerifier = this._generateCodeVerifier();<br>    query.code_challenge = createHash(&#39;sha256&#39;)<br>        .update(this._codeVerifier)<br>        .digest()<br>        .toString(&#39;base64&#39;)<br>        .replace(/\+/g, &#39;-&#39;)<br>        .replace(/\//g, &#39;_&#39;)<br>        .replace(/=/g, &#39;&#39;);<br>    query.code_challenge_method = &#39;S256&#39;;<br>}<br>return this.createUrl(`${this._authorizeEndpoint}?${qs.stringify(query)}`, {addServer: true});</pre><p>The code_verifier need to generated for every authorization request. We update it when we create authorization URI. And save it in local, and generate code_challenge from code_verifier . code_challenge and code_challenge_method need to be added into authorization URI query.</p><p>After user login successfully in authorization URI, we will get authorization code from redirect URI.</p><p>Then we need to exchange access token with “authorization code” and code_verifier :</p><pre>body.grant_type = &#39;authorization_code&#39;;<br>body.code = code;<br>body.redirect_uri = this._redirectUri;<br>if (this._codeVerifier &amp;&amp; this._codeVerifier.length &gt; 0) {<br>    body.code_verifier = this._codeVerifier;<br>    body.client_id = this._clientId;<br>    skipAuthHeader = true;<br>}<br>response = await this._tokenRequest(tokenEndpoint, body, skipAuthHeader);</pre><p>We also need to pass client id in request body, and skip authorization header.</p><p>As we can only exchange token with `authorization code` and `code_verifier`, so it can keep <strong>safe</strong> even your `authorization code` is leaked.</p><p>To get full code for PKCE implement, please go <a href="https://github.com/ringcentral/ringcentral-js/blob/master/sdk/src/platform/Platform.ts#L279">here</a>.</p><h3>Conclusion</h3><p>In this article, we introduced how to authorize RingCentral APIs with the authorization code flow using PKCE, and compared it with the authorization code and implicit grant flow. If you are implementing a client-side(desktop, mobile and web single page apps) app with the RingCentral API, it is recommended to use the PKCE flow which can make your app more stable and safe.</p><p>Please let us know what you think by leaving your questions and comments below. To learn even more about other features we have make sure to visit our <a href="https://developers.ringcentral.com/api-and-docs.html"><strong>developer site</strong></a><strong> </strong>and if you’re ever stuck make sure to go to our <a href="https://forums.developers.ringcentral.com/index.html"><strong>developer forum</strong></a><strong>.</strong></p><p><em>Want to stay up to date and in the know about new APIs and features? Join our </em><a href="https://gamechanging.dev/"><strong><em>Game Changer Program</em></strong></a><em> and earn great rewards for building your skills and learning more about RingCentral!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9108f04b5f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ringcentral-developers/use-authorization-code-pkce-for-ringcentral-api-in-client-app-e9108f04b5f0">Use Authorization Code + PKCE for RingCentral API in Client App</a> was originally published in <a href="https://medium.com/ringcentral-developers">RingCentral Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sync RingCentral Call Log into Google Sheets with Google Apps Script]]></title>
            <link>https://medium.com/ringcentral-developers/sync-ringcentral-call-log-into-google-sheets-with-google-apps-script-daacc9a73b72?source=rss-deab83a07f35------2</link>
            <guid isPermaLink="false">https://medium.com/p/daacc9a73b72</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[developer]]></category>
            <dc:creator><![CDATA[Embbnux Ji]]></dc:creator>
            <pubDate>Tue, 26 May 2020 17:31:01 GMT</pubDate>
            <atom:updated>2020-05-26T17:31:01.449Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1sIOae7aVUcswtyTkMkY_g.png" /></figure><p>As a user of RingCentral, you must have requirements to archive and analysis your calls, messages and meeting data. Google Sheets is a great tool to collect and analysis data. And how can we import or archive RingCentral data into Google Sheets?</p><p>In a previous article, I introduce how to use <a href="https://medium.com/ringcentral-developers/using-ringcentral-api-in-google-apps-script-a91c3367f37c">RingCentral API in Google Apps Script</a>. In this article, I would like to show you to how to create a Google Sheets add-on to help people sync RingCentral call log into spreadsheets.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FKFZYqYbCfWc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DKFZYqYbCfWc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKFZYqYbCfWc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ac7533daf3ca85b1d897d2a96197755/href">https://medium.com/media/5ac7533daf3ca85b1d897d2a96197755/href</a></iframe><h3>Prerequisites</h3><ol><li>Base knowledge about <a href="https://medium.com/ringcentral-developers/using-ringcentral-api-in-google-apps-script-a91c3367f37c">RingCentral API in Google Apps Script</a></li><li>A free <a href="https://developer.ringcentral.com/">RingCentral Developer</a> account to create a RingCentral app</li><li>Google <a href="https://script.google.com/home">Apps Script</a></li><li>Node.js ≥ 10 in local environment</li></ol><blockquote><strong>Please create a RingCentral app and Google Apps Script account as we mentioned in this </strong><a href="https://medium.com/ringcentral-developers/using-ringcentral-api-in-google-apps-script-a91c3367f37c"><strong>article</strong></a><strong>.</strong></blockquote><h3>Setup project</h3><p>We open sourced this project in <a href="https://github.com/embbnux/ringcentral-data-for-google-sheets">the Github repository</a>. So first let’s start by cloning it:</p><pre>$ git clone <a href="https://github.com/embbnux/ringcentral-data-for-google-sheets.git">https://github.com/embbnux/ringcentral-data-for-google-sheets.git</a><br>$ cd ringcentral-data-for-google-sheets</pre><p>Install dependencies:</p><pre>$ yarn</pre><p>Create app_credentials.ts file in a project root path:</p><pre>$ touch app_credentials.ts</pre><p>Add the following code into theapp_credentials.ts file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/afab1542ce058739b4a3d8053ad45d4a/href">https://medium.com/media/afab1542ce058739b4a3d8053ad45d4a/href</a></iframe><blockquote><strong><em>Note</em></strong>: we need to add permission `ReadAccount` and `ReadCallLog` into your RingCentral app.</blockquote><p>We build this project based on the Google Apps Script CLI tool <a href="https://developers.google.com/apps-script/guides/clasp">clasp</a> and <a href="https://developers.google.com/apps-script/guides/typescript">TypeScript</a>.</p><h4>Log into Google Apps Script and Create project with CLI</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b63fe66a4d94336f28c33ebb70930ae4/href">https://medium.com/media/b63fe66a4d94336f28c33ebb70930ae4/href</a></iframe><p>After you use the upper commands, we will create a new Google Apps Script. You can get it <a href="https://script.google.com/home/my">here</a>.</p><h4>Compile and upload code into Google Apps Script</h4><pre>yarn watch</pre><p>Before we test, we need to add the following redirect URI into your RingCentral app on the RingCentral Developer website as we mentioned in the <a href="https://medium.com/ringcentral-developers/using-ringcentral-api-in-google-apps-script-a91c3367f37c">previous article</a>:</p><pre><a href="https://script.google.com/macros/d/%7BGOOGLE">https://script.google.com/macros/d/{GOOGLE</a> SCRIPT ID}/usercallback</pre><p>Go to your <a href="https://script.google.com/home/my">Google Apps Script project</a> to test it as an add-on with a spreadsheet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6a464Xlne9Mgmxfu_f4Sig.png" /></figure><h3>How it works</h3><p>There are two steps to sync the RingCentral call log into Google Sheets.</p><h4>Sync call log data from RingCentral platform API</h4><p>We can get full document from <a href="https://developers.ringcentral.com/guide/voice/call-log/sync">RingCentral call log guide</a>. For requesting RingCentral API in Google Apps Script, you can get the base knowledge <a href="https://medium.com/ringcentral-developers/using-ringcentral-api-in-google-apps-script-a91c3367f37c">here</a>.</p><ol><li>Request the RingCentral call log list API</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34009a5fbad0abc8293a04942c2a0e27/href">https://medium.com/media/34009a5fbad0abc8293a04942c2a0e27/href</a></iframe><p>2. Full sync RingCentral call log data</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f39ab103372d91692da16057e1fa54f/href">https://medium.com/media/7f39ab103372d91692da16057e1fa54f/href</a></iframe><blockquote><strong><em>Notice</em></strong>: When call log records are more than 250, we can’t get all data in a request. So we will request older data with fetchCallLogList.</blockquote><p>3. Incremental Sync of the RingCentral call log</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/71378a8759bf61f96cbc431186463a97/href">https://medium.com/media/71378a8759bf61f96cbc431186463a97/href</a></iframe><blockquote><strong><em>Note</em></strong>: In the`incremental sync` API, when incremental records are more than 250, it will throw an error. So we need to use the `full sync` instead of the `incremental sync`.</blockquote><p>4. Sync and store syncInfo in Google Apps Script properties service</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fcfcbfec7ab0b4ce61ad2ed9003c1135/href">https://medium.com/media/fcfcbfec7ab0b4ce61ad2ed9003c1135/href</a></iframe><h4>Show call log sync options dialog</h4><p>We allow user to select Sync Type , Date From , Account Level and Insert Type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3dFsaPCV1-zIRVhv.png" /></figure><p>To show the dialog:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d449807b276b69e077077579f78d886/href">https://medium.com/media/7d449807b276b69e077077579f78d886/href</a></iframe><p>Insert call log into sheet:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3c7712fe53706867b9aa5f027e57ff0/href">https://medium.com/media/e3c7712fe53706867b9aa5f027e57ff0/href</a></iframe><h3>Conclusion</h3><p>In this article, we introduced how to get the full RingCentral call log data using Google Apps Script to be able to insert the data into Google Sheets. Hopefully this article was helpful. You can get full source code <a href="https://github.com/embbnux/ringcentral-data-for-google-sheets">here</a>.</p><p>Please let us know what you think by leaving your questions and comments below.</p><p>To learn even more about other features we have make sure to visit our <a href="https://developers.ringcentral.com/api-and-docs.html"><strong>developer site</strong></a><strong> </strong>and if you’re ever stuck make sure to go to our <a href="https://forums.developers.ringcentral.com/index.html"><strong>developer forum</strong></a><strong>.</strong></p><p><em>Want to stay up to date and in the know about new APIs and features? Join our </em><a href="https://gamechanging.dev/"><strong><em>Game Changer Program</em></strong></a><em> and earn great rewards for building your skills and learning more about RingCentral!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=daacc9a73b72" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ringcentral-developers/sync-ringcentral-call-log-into-google-sheets-with-google-apps-script-daacc9a73b72">Sync RingCentral Call Log into Google Sheets with Google Apps Script</a> was originally published in <a href="https://medium.com/ringcentral-developers">RingCentral Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrate RingCentral Phone Features with the RingCentral Call SDK]]></title>
            <link>https://medium.com/ringcentral-developers/integrate-ringcentral-phone-features-with-the-ringcentral-call-sdk-a033ef5b7c8c?source=rss-deab83a07f35------2</link>
            <guid isPermaLink="false">https://medium.com/p/a033ef5b7c8c</guid>
            <category><![CDATA[sdk]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ringcentral]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Embbnux Ji]]></dc:creator>
            <pubDate>Tue, 12 May 2020 17:31:01 GMT</pubDate>
            <atom:updated>2020-05-12T17:31:01.300Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QJZowreLpdCbhvaY3Cl9Kg.png" /></figure><p>For developers who want to integrate RingCentrals phone service, we provide the RingCentral WebRTC service and RESTful Call Control APIs for voice transmission and call control. And now we also have the RingCentral Call SDK to help developers to make and control calls easily and functionally.</p><p>We are happy to announce the new <a href="https://github.com/ringcentral/ringcentral-call-js">RingCentral Call SDK for Javascript</a>.</p><h3>Key features:</h3><ul><li><strong>Call session management.</strong> Combined web phone session from WebRTC and telephony session from the Call Control API</li><li><strong>Call session event.</strong> Handle telephony session event, sync status</li><li><strong>Session functional API.</strong> Request call control API with function</li><li><strong>Functional API</strong> to make and receive calls</li></ul><h3>Comparing with the RingCentral Web Phone and Call Control SDK</h3><p><strong>RingCentral Web Phone : </strong>connect user with the WebRTC and SIP based on WebSockets. Can only control the call in the current web phone device</p><p><strong>RingCentral Call Control</strong>: control calls with RESTful APIs, this doesn’t support voice transmission, support to control all calls in current extension user, or account level (admin).</p><p><strong>RingCentral Call</strong>: voice transmission with WebRTC, control calls with RESTful APIs, support to control all calls in current extension user.</p><h3>Quickstart</h3><p>The SDK is based on the <a href="https://github.com/ringcentral/ringcentral-js">RingCentral JS SDK</a> and <a href="https://github.com/ringcentral/ringcentral-web-phone/">RingCentral Web Phone SDK</a>. We use the JS SDK to authorize and register the web phone service — see code example below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5b9dd2ded2f2efa0f5a000081aaff43/href">https://medium.com/media/c5b9dd2ded2f2efa0f5a000081aaff43/href</a></iframe><p>To listen to a call session event you can use this code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de3be9dcb2f0719ae18800f9056c8972/href">https://medium.com/media/de3be9dcb2f0719ae18800f9056c8972/href</a></iframe><p>To make a outbound call:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/949e6822a02690b9a08a3209cdf2cfd1/href">https://medium.com/media/949e6822a02690b9a08a3209cdf2cfd1/href</a></iframe><p>To get the call session list all you need to do is use this single line of code:</p><pre>var sessions = rcCall.sessions;</pre><p>To control the call session use this code below:</p><pre>session.hold().then(...);<br>session.unhold().then(...);<br>session.toVoicemail().then(...);</pre><h3>Online demo</h3><p>We created an online demo that you can check out on this <a href="https://ringcentral.github.io/ringcentral-call-js/">Github page</a>. Here are some screenshots so you can see how it works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SvR7qWOrWdDFGnZs49v3Sg.jpeg" /><figcaption>Receive inbound call</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p9psbLFBay3wQzG_x43hWA.jpeg" /><figcaption>Make a outbound call</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r1td-jEkbaQUiE3Y1lbS_g.jpeg" /><figcaption>handle call</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LwTtE8Ia_OIHoxkgZVH4DQ.jpeg" /><figcaption>Get all calls</figcaption></figure><p>Get the demo source codes <a href="https://github.com/ringcentral/ringcentral-call-js/tree/master/demo">here</a>.</p><h3>Summary</h3><p>That’s all about the Call JS SDK. If you are interested in learning more on how to integrate the RingCentral phone service, then make sure to go to our <a href="https://github.com/ringcentral/ringcentral-call-js">github </a>page to find out even more about this SDK and make things even easier for yourself. Feel free to try it out and create issues <a href="https://github.com/ringcentral/ringcentral-call-js/issues">here</a> if you encounter any problems.</p><p>To learn even more about other features we have make sure to visit our <a href="https://developers.ringcentral.com/api-and-docs.html"><strong>developer site</strong></a><strong> </strong>and if you’re ever stuck make sure to go to our <a href="https://forums.developers.ringcentral.com/index.html"><strong>developer forum</strong></a><strong>.</strong></p><p><em>Want to stay up to date and in the know about new APIs and features? Join our </em><a href="https://gamechanging.dev/"><strong><em>Game Changer Program</em></strong></a><em> and earn great rewards for building your skills and learning more about RingCentral!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a033ef5b7c8c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ringcentral-developers/integrate-ringcentral-phone-features-with-the-ringcentral-call-sdk-a033ef5b7c8c">Integrate RingCentral Phone Features with the RingCentral Call SDK</a> was originally published in <a href="https://medium.com/ringcentral-developers">RingCentral Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>