Build your web app

The UI for an Action using Interactive Canvas is built as a web app. You can use existing web technologies (HTML, CSS, and JavaScript) to design and develop your UI. Before you begin designing your UI, consider the design principles outlined in the Design guidelines section.

The HTML and JavaScript for your web app do the following:

  • Declare Interactive Canvas event callbacks.
  • Initialize the Interactive Canvas JavaScript library.
  • Provide custom logic for updating your web app based on the state.

While you can use whatever method you want to build your UI, we recommend the following methods:


Take the following restrictions into consideration as you develop your web app:

  • No cookies
  • No local storage
  • No geolocation
  • No camera usage
  • No popups
  • Origin is set to null for AJAX
  • Stay under the 200mb memory limit
  • 3P Header takes up upper portion of screen
  • No styles can be applied to videos
  • Only one media element may be used at a time
  • No HLS video
  • Assets must accept requests from null origins


We strongly recommend using a single-page application architecture. This allows for optimal performance and supports continuous conversational UX.


The HTML file defines how your UI looks. This also loads the JavaScript for your HTML, which facilitates communication between your Action and Interactive Canvas.

<!DOCTYPE html>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Immersive Canvas Sample</title>
    <!-- Disable favicon requests -->
    <link rel="shortcut icon" type="image/x-icon" href="data:image/x-icon;,">
    <!-- Load Interactive Canvas JavaScript -->
    <script src=""></script>
    <!-- Load PixiJS for graphics rendering -->
    <script src=""></script>
    <!-- Load Stats.js for fps monitoring -->
    <script src=""></script>
    <!-- Load custom CSS -->
    <link rel="stylesheet" href="css/main.css">
    <div id="view" class="view">
      <div class="debug">
        <div class="stats"></div>
        <div class="logs"></div>
    <!-- Load custom JavaScript after elements are on page -->
    <script src="js/main.js"></script>
    <script src="js/log.js"></script>

Communicate between your fulfillment and web app

Now that you have built your web app and fulfillment, you need to define the communication between them. You can enable this communication with the interactiveCanvas JavaScript that you include in your web app file.

Web app custom logic

This file contains the code to define callbacks and invoke methods through interactiveCanvas. Callbacks provide a way for you to respond to information or requests from the conversational Action, while the methods provide a way to send information or requests to the intent fulfillment.

Add interactiveCanvas.ready(callbacks); to your HTML file to initialize and register callbacks.

// main.js
const view = document.getElementById('view');

// initialize rendering and set correct sizing
const renderer = PIXI.autoDetectRenderer({
  antialias: true,
  width: view.clientWidth,
  height: view.clientHeight,

// center stage and normalize scaling for all resolutions
const stage = new PIXI.Container();
stage.position.set(view.clientWidth / 2, view.clientHeight / 2);
stage.scale.set(Math.max(renderer.width, renderer.height) / 1024);

// load a sprite from a svg file
const sprite = PIXI.Sprite.from('triangle.svg');
sprite.tint = 0x00FF00; // green

let spin = true;
// register interactive canvas callbacks
const callbacks = {
  onUpdate(data) {
    console.log('onUpdate', JSON.stringify(data));
    if ('tint' in data) {
      sprite.tint = data.tint;
    if ('spin' in data) {
      spin = data.spin;

// toggle spin on tap of the triangle
sprite.interactive = true;
sprite.buttonMode = true;
sprite.on('pointerdown', () => {
  spin = !spin;

// code to be ran per frame
let last =;
const frame = () => {
  // calculate time differences for smooth animations
  const now =;
  const delta = now - last;

  // rotate the triangle only if spin is true
  if (spin) {
    sprite.rotation += delta / 1000;

  last = now;


User says versus user does

Per the Interactive Canvas design guidelines, you should develop your Action with "voice-first" in mind. That being said, some Smart Displays support touch interactions. Supporting touch is similar to creating a conversational Action, but instead of a vocal response from the user, your client-side JavaScript looks for touch interactions and uses those to change elements in the web app.

You can see an example of this in our sample, which uses the Pixi.js library:

const sprite = PIXI.Sprite.from('triangle.svg');
sprite.interactive = true; // Enables interaction events
sprite.buttonMode = true; // Changes `cursor` property to `pointer` for PointerEvent
sprite.on('pointerdown', () => {
  spin = !spin;

In this case, the value of the spin variable is sent through the interactiveCanvas API as an update callback. The fulfillment has logic that triggers an intent based on the value of spin.

app.intent('pause', (conv) => {
  conv.ask(`Ok, I paused spinning. What else?`);
  conv.ask(new HtmlResponse({
    data: {
      spin: false,