Text Messages

A Text Message has a few uses:

  • A standard conversational message containing messages users type to one another
  • A framed and titled Message for quoted text. For example, a quote from a product manual or a product page might be rendered, and attribution given as to where it came from so that it does not look like something that the sender just typed in.
Text Message with Details
Text Message without Details

The above illustrates the difference between a Text Message that is rendered as a conversational message, and a Text Message that renders quoted text with a title and footer.

Field Required Type Description
mime_type Yes String application/vnd.layer.text+json
text Yes String This is the core data rendered by the Core UI for this Message
title No String Title for the Text Message
subtitle No String Rendered below the title
author No String Rendered below the subtitle
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

If text is provided, but no title, subtitle or author then this Text Message will render as a regular chat bubble rather than look like a quoted message with metadata shown below it:

SAPI payload for creating a Basic Text Message:

{
	"sender_id": "layer:///identities/frodo-the-dodo",
	"parts": [
		{
			"id": "layer:///messages/GENERATE_A_UUID/parts/GENERATE_A_UUID",
			"mime_type": "application/vnd.layer.text+json;role=root",
			"body": JSON.stringify({
        "text": "hello"
      })
		}
	]
}

SAPI payload for a Full Text Message:

{
	"sender_id": "layer:///identities/frodo-the-dodo",
	"parts": [
		{
			"id": "layer:///messages/GENERATE_A_UUID/parts/GENERATE_A_UUID",
			"mime_type": "application/vnd.layer.text+json;role=root",
			"body": JSON.stringify({
        "text": "hello",
        "title": "This is not a terribly short title"
      })
		}
	]
}