Homepages (original) (raw)

Homepages are an Google Workspace add-ons feature that provides the ability to define one or more non-contextual cards. Non-contextual cards display a user interface when the user is outside a specific context, such as when viewing their Gmail inbox without an open message or draft.

Homepages let you show non-contextual content, similar to the Google apps in the quick-access side panel(Google Keep, Google Calendar, and Google Tasks). Homepages can also provide an initial starting place when a user first opens your add-on and are useful for teaching new users how to interact with your add-on.

Define a homepage for your add-on by specifying it in your project manifest and implementing one or more homepageTriggerfunctions (see Homepage configuration).

You can have multiple homepages, one for each host application that your add-on extends. You can also define a single common default homepage that is used in hosts where you haven't specified a custom homepage.

Your add-on homepage is displayed in these cases:

Designing a homepage is recommended. If you don't define any, a generic card containing your add-on name is used whenever a user navigates to the homepage.

Homepage configuration

Google Workspace add-ons use the addOns.common.homepageTrigger field to configure the default homepage (non-contextual) add-on content for host applications in the add-on manifest:

{
  "addOns": {
    "common": {
      "homepageTrigger": {
        "runFunction": "myFunction",
        "enabled": true
      }
    }
  }
}

For a host to use the common homepage, bothaddOns.common.homepageTrigger and the host's top-level resource must be present in the add-on manifest. For example, ifaddOns.gmail isn't present in the manifest, then the add-on is disabled for Gmail and won't show a homepage or other functionality in that host.

In addition to the common configuration, identically-structured per-host overrides are available in each host application's config, ataddOns.gmail.homepageTrigger, addOns.calendar.homepageTrigger, and other host-specific triggers.

The following example shows a manifest where a common homepage trigger is defined but is overridden with custom functions for Calendar and Drive, and disabled for Gmail. In this configuration, the common buildHomePage function never executes because it is either overridden or the host is disabled.

{
  ...
  "addOns": {
    ...
    "common": {
      "homepageTrigger": { "runFunction": "buildHomePage" }
    },
    "calendar": {
      "homepageTrigger": { "runFunction": "buildCalendarHomepage" }
    },
    "drive": {
      "homepageTrigger": { "runFunction": "buildDriveHomepage" }
    },
    "gmail": {
      "homepageTrigger": { "enabled": false }
    },
    ...
  }
}

The following manifest excerpt is equivalent to the previous example, even though the default homepageTrigger and the Gmail configuration are omitted:

{
  "addOns": {
    "common": {},
    "calendar": {
      "homepageTrigger": { "runFunction": "myCalendarFunction" }
    },
    "drive": {
      "homepageTrigger": { "runFunction": "myDriveFunction" }
    },
    "gmail": {},
    ...
  }
}

None of the homepageTrigger sections are required. The UI shown for an add-on in a host product depends on the presence of the corresponding manifest field and whether there's an associatedhomepageTrigger. The following example shows which add-on trigger functions are executed to create a homepage UI for different manifest configurations:

Diagram showing add-on homepage trigger function execution flow

Homepage event objects

When called, the homepage trigger function (runFunction) described previously is passed an event objectcontaining data from the invocation context.

Homepage event objects don't include widget or contextual information. The information passed is limited to the followingcommon event objectfields:

See Event object for more details.

Other non-contextual cards

Your add-on UI can contain additional non-contextual cards that aren't homepages. For example, your homepage might have a button that opens a "Settings" card to adjust add-on settings (such settings are usually independent of context).

Non-contextual cards are built like any other card; the only difference is what action or event generates and displays the card. SeeNavigation methodsfor details on how to create transitions between cards.