ReferenceComponents

actions

One or two buttons for what to do about the thing on screen.

What to do about it. actions is one or two buttons beside what the answer is about: "Add to cart", "Choose a size", "Open the site". The first is the one that matters most.

On a detail page the first is also drawn lit beside the microphone, where the thumb already is, and the buttons on the page stay quiet. On an answer page the first is the primary button and the second a quiet one.

Add to cartChoose a size

Drawn live in your browser with the SDK’s own sizes and colours, not a screenshot.

Rendered natively by the Flutter SDK since 0.35.0 and the web SDK since 0.12.0. A build that does not declare it is never offered it.

When not to use it

Not for questions to go on with, which are quick_replies: an action does something about this thing, a quick reply asks about something next.

Not as a way round a confirmation. A reply action asks, in the user's voice, for something to be done ("Add size 43 to my cart"); if that is a write, Rendel still answers it with a confirm_card the user has to accept.

Props

Every block also carries type and a required fallback_text of 1 to 300 characters.

PropTypeRequiredConstraints
itemsarrayYes1 to 2 entries.
items[].labelstringYes1 to 40 characters.
items[].iconstringNoUp to 40 characters.
items[].actionactionYes{ kind: "reply", text } or { kind: "open_url", url } or { kind: "navigate", route } or { kind: "call", phone } or { kind: "copy", text } or { kind: "add_to_calendar", title, starts_at }. See Actions.

On the wire

{
  "id": "blk_40",
  "type": "actions",
  "fallback_text": "Add Aero Glide 2 to the cart, or choose a size.",
  "props": {
    "items": [
      { "label": "Add to cart", "icon": "bag", "action": { "kind": "reply", "text": "Add size 43 to my cart" } },
      { "label": "Choose a size", "action": { "kind": "reply", "text": "Which sizes are in stock?" } }
    ]
  }
}

Interaction

A reply sends its text as the user's next message: on a detail page the detail closes and the answer opens as a new page. open_url opens the link and leaves everything where it is.

An item can carry any kind the build declares: navigate opens a screen you registered (prefer a screens block when opening a screen is the point), call opens the dialler, copy puts a value on the clipboard, and add_to_calendar opens the device's event editor. The server checks a route, a number, a copied value and calendar times before the block leaves; a block that fails is shown as its fallback_text.

Accessibility

Each button is announced by its label. The icon is decoration; the label says what happens.