Carousel Messages

The Carousel Message presents an arbitrary collection of sub-message-views in a left-right scrolling view.

While one can create a Carousel that contains a mix of Image Messages, Text Messages, Product Messages, Button Messages, etc… for best results, the Caroursel items:

  1. Should all be of the same type
  2. Should all contain similar sizes and quantities of content
Carousel of File Messages
Name Required Type Description
mime_type Yes String application/vnd.layer.carousel+json
custom_data No Object Data that will not be understood by any Layer provided Renderer, but which will allow additional context to be stored in the Message so your server can better understand it when next your server sees the Message

Message Part Roles:

Name Required Type Description
carousel-item Y Any Message Type Each carousel item is a top level item to scroll to/past within the carousel

A Carousel consists of a collection of Message Parts that area carousel-item parts; each such item will be rendered as an item within the carousel. Each carousel-item:

  1. Specifies that it is a carousel-item using the MIME Type Attribute
  • role=carousel-item
  1. Specifies that it is a child of the Carousel Message Part:
  • parent-node-id=uuid-of-carousel-root
  1. Specifies its own Message, and can be any Message defined in this document or any Custom Message your clients understand
  • application/vnd.layer.image+json

SAPI payload for creating a Carousel of File Messages:

{
	"sender_id": "layer:///identities/frodo-the-dodo",
	"parts": [
		{
			"id": "layer:///messages/GENERATE_A_UUID/parts/" + id1,
			"mime_type": "application/vnd.layer.carousel+json;role=root",
			"body": "{}"
		},
    {
      "mime_type": "application/vnd.layer.file+json;role=carousel-item;parent-node-id=" + id1,
      "body": JSON.stringify({
        "title": "License",
        "source_url": "https://raw.githubusercontent.com/layerhq/web-xdk/master/LICENSE",
      });
    },
    {
      "mime_type": "application/vnd.layer.file+json;role=carousel-item;parent-node-id=" + id1,
      "body": JSON.stringify({
        "title": "Readme",
        "source_url": "https://raw.githubusercontent.com/layerhq/web-xdk/master/README.md",
      });
    },
    {
      "mime_type": "application/vnd.layer.file+json;role=carousel-item;parent-node-id=" + id1,
      "body": JSON.stringify({
        "title": "Change Logs",
        "source_url": "https://raw.githubusercontent.com/layerhq/web-xdk/master/Changelog.md",
      });
    },
	]
}