Skip to content

Show

adaptive_card(card)

Creates and validates the data for an adaptive card. See https://adaptivecards.io/

attachment(value)

Constructs a new attachment.

audio(url)

Creates and validates a data structure for presenting an audio fragment.

The result is meant to be passed in to the show statement, e.g: show audio("http://example.com/…")

buttons(text, buttons)

Creates and validates a data structure for showing a buttons template

For more info on the exact data format see https://developers.facebook.com/docs/messenger-platform/reference/template/button

card_template(opts)

Creates a card template. A card template is a gallery template with only one item. This is not supported on Facebook Messenger, only on web and google assistant.

contact(attrs)

Creates a contact object.

A contact object can be shown to the user with show.

Examples:

Most fields are optional. This is an example of a full contact object:

iex> contact(%{
...>   name: %{
...>     first_name: "First",
...>     middle_name: "Middle",
...>     last_name: "Last",
...>     prefix: "Prefix",
...>     suffix: "Suffix",
...>     formatted_name: "Prefix First Middle Last Suffix"
...>   },
...>   birthday: "1970-01-01",
...>   emails: [
...>     %{type: "home", email: "home@example.com"},
...>     %{type: "work", email: "work@example.com"}
...>   ],
...>   org: %{
...>     company: "Company",
...>     department: "Department",
...>     title: "Role title"
...>   },
...>   phones: [
...>     %{type: "home", phone: "0612345678"},
...>     %{type: "work", phone: "0612345678"}
...>   ],
...>   urls: [
...>     %{type: "home", url: "https://example.com/home"},
...>     %{type: "work", url: "https://example.com/work"}
...>   ],
...>   addresses: [
...>     %{
...>       type: "work",
...>       street: "Street",
...>       city: "City",
...>       state: "State / Province",
...>       zip: "ZIP",
...>       country: "Country",
...>       country_code: "country code (e.g. nl, de, etc)",
...>     }
...>   ]
...> })

file(url)

Creates and validates a data structure for offering a file for download.

The result is meant to be passed in to the show statement, e.g: show file("http://example.com/…")

Creates and validates a data structure for showing a horizontal gallery template.

Options: pass in modal: false to prevent the elements showing in a modal gallery popup, but as large elements in the chat stream instead.

For more info on the exact data format see https://developers.facebook.com/docs/messenger-platform/reference/template/generic

image(url)

Creates and validates a data structure for showing an image.

The result is meant to be passed in to the show statement, e.g: show image("http://example.com/…")

input_method(type, config \\ nil)

Creates and validates a data structure for the given input method, to be used in an expecting: clause.

See the documentation for more details on different input methods.

list_template(elements, button \\ nil, top_element_style \\ "compact")

Creates and validates a data structure for showing a list template.

For more info on the exact data format see https://developers.facebook.com/docs/messenger-platform/reference/template/list

location(value, opts \\ [])

Convert the given value to a valid location structure

message(message, opts \\ %{})

Constructs a new message struct.

This does not perform any kind of NLP classification, so intent matching does not automatically work; you'll have to assign the intent manually.

template(type, payload)

Show a specific rich template in the chat stream.

The following templates are known:

  • buttons
  • gallery
  • list
  • adaptive_card
  • text

video(url)

Creates and validates a data structure for showing a video clip.

The result is meant to be passed in to the show statement, e.g: show video("http://example.com/…")

web(url)

Creates and validates a data structure for showing a website in an iframe.

The result is meant to be passed in to the show statement, e.g: show web("http://example.com/…")