OneRoute
  • Introduction
  • Prerequisites
  • Whatsapp API
    • Sandbox (Test API Key)
    • Getting Started
    • Endpoints
      • Fetch Channels
      • Fetch Channel Templates
      • Send Template Message
      • Send Campaign Message
      • Send Session Message
    • FAQ
  • EMAIL API
    • Getting Started
    • Endpoints
      • Fetch Email Channels
      • Send Email to Customers
  • SMS API
    • Getting Started
    • Endpoints
      • Fetch SMS Channels
      • Send SMS to Customers
      • Send OTP SMS to Customers
      • Fetch SMS Messages
      • Get SMS DLR Message
  • ONEOTP API
    • Getting Started
    • Endpoints
      • Fetch OTP Templates
      • Send OTP
      • Verify OTP
  • EMBED
    • Getting Started
    • Installation
    • Push Notification
  • OTHERS
    • Receiving Events - Webhooks
    • Fetch Channel By Id
    • Fetch Logs
Powered by GitBook
On this page
  • Standard Installation
  • Single Page App

Was this helpful?

  1. EMBED

Installation

PreviousGetting StartedNextPush Notification

Last updated 1 year ago

Was this helpful?

We support two different ways to install OneRoute Embed on your website. The first is a and will work for most websites. The second is for a .

First, you need to ensure that you are on a Business plan to use this.

Standard Installation

If you have a web app with multiple pages where each one triggers a new page refresh then you will most likely need the basic JavaScript method. This means you will not need to create separate actions that trigger when the Embed will appear. The page refresh itself is enough to trigger the action. To set up the basic JavaScript, you will only need to follow these steps.

How to Install

To get the Embed to appear on your web app, you need to set the element you want it to show within.

<div id="onerouteEmbed"></div>

Then, copy and paste the snippet below before the </body> tag.

<script>
  const orEmbedConfig = {
    api_key: "API_KEY",
    firm_id: "FIRM_ID",
    business_name: user.business.name, //User's business name
    business_id: user.business.id, //User's business id
    user_first_name: user.firstname,
    user_last_name: user.lastname,
    user_email: user.email,
    
    // Optional keys
    style: {"primary_color": "#FF33F0"},
  };

  function loadOneRouteEmbed() {
    const orEmbedEl = document.getElementById("onerouteEmbed");
    if (orEmbedEl) {
      orEmbedEl.className = "oneroute_embed";
      orEmbedEl.setAttribute("data-config", JSON.stringify(orEmbedConfig));
    
      const scriptElement = document.createElement("script");
      scriptElement.src = "https://rebrand.ly/or-embed";
      document.body.appendChild(scriptElement);
    }
  }
  loadOneRouteEmbed();
</script>

Single Page App

If you have a single-page app, then you can get OneRoute Embed installed on your page. So let's waste no time and get you chatting with your customers.

How to Install

To get the Embed to appear on your web app, you need to set the element on the page/component you want it to show within.

<div id="onerouteEmbed"></div>

Then, copy and paste the snippet below into the page on-mount function (useEffect, componentDidMount, ngAfterViewInit, mounted, etc).

const orEmbedConfig = {
  api_key: "API_KEY",
  firm_id: "FIRM_ID",
  business_name: user.business.name, //User's business name
  business_id: user.business.id, //User's business id
  user_first_name: user.firstname,
  user_last_name: user.lastname,
  user_email: user.email,
    
  // Optional keys
  style: {"primary_color": "#FF33F0"},
};

function loadOneRouteEmbed() {
  const orEmbedEl = document.getElementById("onerouteEmbed");
  if (orEmbedEl) {
    orEmbedEl.className = "oneroute_embed";
    orEmbedEl.setAttribute("data-config", JSON.stringify(orEmbedConfig));
    
    const scriptElement = document.createElement("script");
    scriptElement.src = "https://rebrand.ly/or-embed";
    document.body.appendChild(scriptElement);
  }
}
loadOneRouteEmbed();

This is an example of how it'll look after a successful installation.

You can find your API_KEY and FIRM_ID on your OneRoute Dashboard > Settings > > API Keys & Webhooks.

You can find your API_KEY and FIRM_ID on your OneRoute Dashboard > Settings > > API Keys & Webhooks.

Account Settings
Account Settings
standard installation
single-page app
OneRoute Embed