Media components for widgets

Reference for image, carousel, video and audio, the widget components that show pictures, product cards and media players inside the chat.

Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.

Media components show pictures, product cards and playable files. Use them when seeing the thing is faster than reading about it: a product photo, a set of options to browse or a short how-to clip.

Components

Type Shows
image A single picture.
carousel A row of cards the customer swipes through, each with an image and a title.
video A video player.
audio An audio player.

Properties

Property Applies to Description
src image, video, audio The address of the file. Use https. Can be a binding.
alt image A short description for screen readers. Required.
poster video An image shown before playback starts.
controls video, audio Shows play and pause controls. Default true.
items carousel A binding to a list. Each item has image, title, subtitle and value.
actionLabel carousel The text of the button on each card, such as "Choose".
onSelect carousel The function to run when a card's button is tapped. event.value holds the item's value.
trackAs carousel A name for click tracking.
showIf All A binding. The component appears only when the value is true or non-empty.

Example: product cards

{
  "states": {
    "picks": [
      { "image": "https://www.example.com/img/rain-jacket.jpg", "title": "Rain jacket", "subtitle": "Waterproof, packs small", "value": "sku_jacket" },
      { "image": "https://www.example.com/img/trail-shoe.jpg", "title": "Trail shoe", "subtitle": "Grip for wet ground", "value": "sku_shoe" }
    ]
  },
  "components": [
    {
      "type": "carousel",
      "items": "{{states.picks}}",
      "actionLabel": "Choose",
      "onSelect": "choose",
      "trackAs": "picks_choose"
    }
  ]
}

You should see two cards in a row with a picture, a title, a line of text and a Choose button. Selecting one runs the choose function with that card's value.

The items would normally come from an action instead of being written in the state. Use a callAction step with saveTo set to picks. See Functions.

Example: single image

{ "type": "image", "src": "{{states.order.photoUrl}}", "alt": "Photo of the item you ordered" }

Tips

  • Always write alt text. Describe what the picture shows, not that it is a picture.
  • Use files that load quickly. Large images make the widget feel slow in the chat window.
  • Add a poster to every video, so the card has a picture before it is played.
  • Keep carousels to a handful of cards. Long rows are hard to browse on a phone.

Note: Media files must be reachable by the customer's browser. Files behind a login do not load inside the chat.

Something unclear or missing? Tell us and we will fix the page.