> ## Documentation Index
> Fetch the complete documentation index at: https://help.revenuehero.io/llms.txt
> Use this file to discover all available pages before exploring further.

# How to show the RevenueHero scheduler inside your app

> Put the RevenueHero scheduler inside your product so logged-in users can book the right rep for upgrades, renewals, support or anything else without filling a form.

Your customers are already logged in to your product, so you know who they are. The RevenueHero scheduler can open right inside your app, take the user's details from your app instead of a form, and route them to the right person: their account owner, support, an expert on the page they're stuck on, or anyone else your rules pick.

This page shows you how to set up a router for it and add the code to your app.

## Use cases

Any time a logged-in user needs to talk to someone on your team, you can offer a meeting from inside the app:

* **Upgrades.** A user on a smaller plan clicks a feature their plan doesn't include and books time with sales.
* **Renewals.** A customer near renewal books with their account manager.
* **Support and help.** A user stuck on a settings page books with the person who knows that part of your product.
* **Account requests.** Anything else a customer would otherwise email about.

The user never types their name or email, because your app sends them in the background.

## How the in-app scheduler works

The in-app scheduler uses the same RevenueHero script and Inbound Router as the scheduler on your website. The difference is where the data comes from. On a website, a visitor fills in a form. Inside your app, your code sends the logged-in user's details to RevenueHero when they click a button or link.

1. The user clicks a button or link in your app, such as **Talk to us**.
2. Your code calls `hero.submit()` with the user's details from your app.
3. RevenueHero runs the router's rules and picks the rep.
4. Your code calls `hero.dialog.open()`, and the scheduler opens on top of your app.

This works anywhere your app can run JavaScript.

## Set up the in-app scheduler

> [!NOTE]
>
> **BEFORE YOU BEGIN**
>
> You need a [Meeting Type](https://help.revenuehero.io/type/create-meeting-type.md) and a [Team](https://help.revenuehero.io/teams/create-teams.md) for the router to book into.

**1. Create a new Inbound Router**

In the left sidebar, click **Inbound**, then **Routers**, then **Create Inbound Router**, and click **Get Started**.

Create a new router for your app instead of reusing the one on your website. In-app requests are a different job from website demo requests, so a separate router keeps your website routing unchanged, lets you write rules for help and account requests, and keeps in-app submissions apart in [Routing Logs](https://help.revenuehero.io/reports/inbound/routing-logs.md). People in an app also often open the scheduler without booking, so a separate router keeps those visits out of your website reports.

The steps below guide you through setting up this router for in-app bookings.

**2. Map a new form for your app**

On **Map a form**, don't pick your website form. Click **Create Form**, then **I'll do this manually**.

![Create Form Mapping panel with Form Name, Webpage url and Form Selector fields](https://mintcdn.com/revenuehero/bqzGQYW12WOFAG3y/images/in_app_scheduler_04_form_mapping_selector.png?fit=max\&auto=format\&n=bqzGQYW12WOFAG3y\&q=85\&s=e6bcb1cba29efc5c451ead9c55f43278)

* **Form Name.** A name you'll recognise, such as `In-app help`.
* **Webpage url where your form is present.** Leave it empty. Your app has no form page.
* **Form Selector.** This field is required to save the form mapping, but it isn't used for in-app bookings. Enter any placeholder, such as `#in-app-help`.

Then map the fields your code will send:

![Map Email and Map Name sections with Form field name inputs and HubSpot contact fields](https://mintcdn.com/revenuehero/bqzGQYW12WOFAG3y/images/in_app_scheduler_05_form_mapping_fields.png?fit=max\&auto=format\&n=bqzGQYW12WOFAG3y\&q=85\&s=2d9d0d85eee91aebb4dcae0fe800f2fe)

* **Email** and **Name** are required. In **Form field name**, type the key your code will send for each, for example `email` and `firstname`.
* **Map Additional Form Inputs** is only needed for fields a routing rule uses, such as plan or region. Your app already knows who the user is, so you rarely need more.

The form field names must match the keys in your code exactly, including capital letters: `Email` and `email` are different keys. If you map `email`, your code sends `email: user.email`. Save the form mapping.

**3. Set the routing rules**

Decide who should take these meetings:

* **Matching rules.** Most of your users are customers who already have an owner in your CRM, and it's usually best that they talk to that person. A matching rule books them with their existing owner. If you don't want owners to take these meetings, leave matching rules off.
* **Distribution rules.** These decide who gets the meeting when there is no owner match. You can route by region, team, or where in your app the user asked for help.

![Distribution rules list with three rules: In-app SEs, In-app US and in-app Non US](https://mintcdn.com/revenuehero/bqzGQYW12WOFAG3y/images/in_app_scheduler_06_distribution_rules.png?fit=max\&auto=format\&n=bqzGQYW12WOFAG3y\&q=85\&s=9ce5bf2d7a00924307a6080ed51b1f89)

An in-app router with distribution rules for Solutions Engineers, US users and non-US users.

To route by page in a web app, add a condition on **Enrichment > Source URL**, which is the page the user was on when they clicked. For example, Source URL **contains** `routing-logs` sends users who ask for help from your routing logs page to the team that knows it best.

![Distribution rule condition: Enrichment Source URL contains routing-logs](https://mintcdn.com/revenuehero/bqzGQYW12WOFAG3y/images/in_app_scheduler_03_source_url_condition.png?fit=max\&auto=format\&n=bqzGQYW12WOFAG3y\&q=85\&s=d07f67a40ae8576e586950177e9f66bc)

You can also route on details your app sends. Your app already knows things like the user's plan or the part of the product they're using. Map that key under **Map Additional Form Inputs** to the matching CRM property, send it in `hero.submit()`, for example `product_area: "billing"`, and add a condition on it from **Form Inputs** in a distribution rule. In a native mobile app, Source URL isn't available, so send a field like this to tell your rules where the user came from.

**4. Configure the router**

On **Configure Router**, pick the meeting type and duration, for example a 15 minute help call. A post-booking form is usually not needed, because you already know who the user is.

Name the router, for example `In-app help router`, and create it.

**5. Copy the in-app snippet**

Open your router and click **Widget Installation**. On the **Website** tab, under **Show the scheduler**, select **Inside your application**. The snippet includes your Router ID.

![Widget Installation with Inside your application selected and the router snippet shown](https://mintcdn.com/revenuehero/bqzGQYW12WOFAG3y/images/in_app_scheduler_02_widget_installation.png?fit=max\&auto=format\&n=bqzGQYW12WOFAG3y\&q=85\&s=71e2f1890d4e8d833b5993bcf26c1907)

The snippet has two placeholders to replace: `#buttonId` with the element your users click, and `field: "value"` with the fields from your form mapping.

**6. Add the code to your app**

Add the RevenueHero script once, in the `<head>` of your app, before any code that uses it.

```html theme={null}
<script type="text/javascript" src="https://assets.revenuehero.io/scheduler.min.js"></script>
```

For a version-locked tag with Subresource Integrity, generate one on [Installation Methods](https://help.revenuehero.io/Inbound-router-installation.md).

Then call the scheduler from whatever the user clicks. The example below uses a button, but any link, menu item or custom event works.

```html theme={null}
<button id="talk-to-us">Talk to us</button>
```

```javascript theme={null}
// The logged-in user's details, from your app's session or state
const user = {
  email: "jane@acme.com",
  firstName: "Jane"
};

const button = document.querySelector("#talk-to-us");

button.addEventListener("click", () => {
  const hero = new RevenueHero({ routerId: "YOUR_ROUTER_ID" });

  // Keys must match the form field names in your form mapping
  hero.submit({
    email: user.email,
    firstname: user.firstName
  }).then((data) => {
    // Opens the scheduler with the rep your rules picked
    hero.dialog.open(data);
  }).catch((error) => {
    console.log(error);
  });
});
```

| Part | What it does |
| - | - |
| `routerId` | Tells RevenueHero which router handles the request. Use the ID from Widget Installation. |
| `hero.submit()` | Sends the user's details to RevenueHero, which runs the router's rules. Pass a plain object. |
| `hero.dialog.open()` | Opens the scheduler with the result from `hero.submit()`. |

To show a loading spinner while the rules run, add `showLoader: true` next to `routerId`. Every option is listed under [Constructor options](https://help.revenuehero.io/Inbound-router-installation.md#constructor-options).

> [!WARNING]
>
> If your account lists any **Trusted Origins** in its [security settings](https://help.revenuehero.io/security-overview.md), add your app's domain to that list, for example `https://app.yourcompany.com`. Once at least one origin is listed, submissions from any other domain are blocked, so the scheduler won't open inside your app until its domain is added.

**7. Test it**

Log in to your app as a test user, click the button, and book a slot. Then open [Routing Logs](https://help.revenuehero.io/reports/inbound/routing-logs.md), filter by your in-app router, and check that the submission went to the rep you expected.

If a rule checks **Source URL**, test from the page in your app that the rule expects. A test from any other page, such as a local test page, won't match that rule and may be routed or disqualified differently.

## Tips for in-app setups

> [accordion] Call hero.submit() on click, not when the screen loads
>
> The router runs every time `hero.submit()` is called. If your app calls it as soon as a screen opens, every user who opens that screen goes through routing and shows up in Routing Logs, whether or not they wanted a meeting. Users who qualify but don't book are also sent to your CRM with the meeting status **Not booked**, so everyone who opened that screen would be marked that way. Call it when the user clicks.

> [accordion] Send one submission per click
>
> Make sure one click calls `hero.submit()` once. If a click fires the handler more than once, which can happen in mobile apps, Routing Logs show duplicate submissions a few seconds apart.

> [accordion] Error: email could not be determined from the form submission
>
> If `hero.submit()` fails with a 422 error and this message, RevenueHero didn't find the email in what your code sent. Check that the key matches the **Form field name** in your form mapping exactly, including capital letters, and that the snippet's `field: "value"` placeholder has been replaced with your real fields.

> [accordion] Allow free email addresses if your users have them
>
> If people sign in to your app with personal addresses, such as Gmail, check that the router's **Disqualification Settings** allow free emails. Otherwise those users are disqualified and never see the scheduler.

> [accordion] Users who aren't in your CRM yet
>
> A brand-new user may not have a CRM record when they click. Matching rules then find no owner, and the user goes to your distribution rules instead. Make sure at least one distribution rule catches them.

> [accordion] Leave out fields your app doesn't have
>
> If an additional field is empty for some users, such as a phone number you only collect in some countries, leave it out of `hero.submit()`. Routing still runs. It fails only if the email is missing or doesn't match your form mapping, or if a rule uses a field that isn't in your form mapping.

> [accordion] Change routing without releasing your app
>
> Your app only holds the Router ID. The rules live in RevenueHero, so you can change who gets which meetings at any time without shipping a new version of your app.

***

Your customers can now book the right person without leaving your product. 🎉

> [card] [Installation Methods](https://help.revenuehero.io/Inbound-router-installation.md)
>
> Every way to call the scheduler, including `hero.submit()`, `hero.dialog.open()` and React examples.

> [card] [Create an Inbound Router](https://help.revenuehero.io/routers/inbound/create-inbound-router.md)
>
> Every step of router setup in detail.

> [card] [What are Matching Rules?](https://help.revenuehero.io/what-are-matching-rules.md)
>
> How a matching rule books a customer with the rep who already owns their account.

> [card] [Routing Logs](https://help.revenuehero.io/reports/inbound/routing-logs.md)
>
> Check where each in-app submission went and why.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.