Create Message

Posts a message to an existing stream.

Post a message to one existing stream.

Post a new message to the given stream. The stream can be a chatroom,,an IM or a multiparty IM.

You may include an attachment on the message.

The message can be provided as MessageMLV2 or PresentationML. Both formats support Freemarker templates.

The optional parameter "data" can be used to provide a JSON payload containing entity data. If the message contains explicit references to entity data (in "data-entity-id" element attributes), this parameter is required.

If the message is in MessageML and fails schema validation a client error will be returned.

If the message is sent then 200 is returned.

Regarding authentication, you must either use the sessionToken which was created for delegated app access or both the sessionToken and keyManagerToken together.

POSTyouragentURL.symphony.com/agent/v4/stream/{sid}/message/create
Path parameters
sid*string

Stream ID

Header parameters
Body
messagestring

The message payload in MessageML.

datastring

Optional message data in EntityJSON.

versionstring

Optional message version in the format "major.minor". If empty, defaults to the latest supported version.

attachmentstring (binary)

Optional file attachment.

previewstring (binary)

Optional attachment preview.

Response

Message sent.

Body
messageIdstring

Id of the message

parentMessageIdstring

Id of the parent message, set when the message is a reply to another message or a forwarded message. Since Agent 20.14.

timestampinteger (int64)

Timestamp of the message in milliseconds since Jan 1 1970

messagestring (MessageMLV2)

Message content in MessageMLV2

sharedMessageV4Message (object)

A representation of a message sent by a user of Symphony

datastring (JSON)

Message data in EntityJSON

attachmentsarray of V4AttachmentInfo (object)

Message attachments

userV4User (object)
streamV4Stream (object)
externalRecipientsboolean

Indicates if the message have external recipients. Only present on real time messaging.

diagnosticstring

Details if event failed to parse for any reason. The contents of this field may not be useful, depending on the nature of the error. Only present when error occurs.

userAgentstring

User agent string for client that sent the message. Allows callers to identify which client sent the origin message (e.g. API Agent, SFE Client, mobile, etc)

originalFormatstring

Indicates the format in which the message was originally sent. This could have been either:

  • com.symphony.markdown - Markdown OR Message ML V1
  • com.symphony.messageml.v2 - Message ML V2
disclaimerstring

Message that may be sent along with a regular message if configured for the POD, usually the first message sent in a room that day.

sidstring

Unique session identifier from where the message was created.

Example: "fa691cd3-484a-4109-aeb2-57c05b78c95b"
replacingstring

Id of the message that the current message is replacing (present only if set)

replacedBystring

Id of the message that the current message is being replaced with (present only if set)

initialTimestampinteger (int64)

Timestamp of when the initial message has been created in milliseconds since Jan 1 1970 (present only if set)

initialMessageIdstring

Id the the initial message that has been updated (present only if set)

silentboolean

When false the user/s will receive the message update as unread (true by default)

Request
const response = await fetch('youragentURL.symphony.com/agent/v4/stream/{sid}/message/create', {
    method: 'POST',
    headers: {
      "sessionToken": "text",
      "Content-Type": "multipart/form-data"
    },
    body: JSON.stringify({}),
});
const data = await response.json();
Response
{
  "messageId": "text",
  "parentMessageId": "text",
  "timestamp": 0,
  "message": "text",
  "data": "text",
  "attachments": [
    {
      "id": "text",
      "name": "text",
      "size": 0,
      "images": [
        {
          "id": "text",
          "dimension": "text"
        }
      ]
    }
  ],
  "user": {
    "userId": 0,
    "firstName": "text",
    "lastName": "text",
    "displayName": "text",
    "email": "text",
    "username": "text"
  },
  "stream": {
    "streamId": "text",
    "streamType": "text",
    "roomName": "text",
    "members": [
      {
        "userId": 0,
        "firstName": "text",
        "lastName": "text",
        "displayName": "text",
        "email": "text",
        "username": "text"
      }
    ],
    "external": false,
    "crossPod": false
  },
  "externalRecipients": false,
  "diagnostic": "text",
  "userAgent": "text",
  "originalFormat": "text",
  "disclaimer": "text",
  "sid": "fa691cd3-484a-4109-aeb2-57c05b78c95b",
  "replacing": "text",
  "replacedBy": "text",
  "initialTimestamp": 0,
  "initialMessageId": "text",
  "silent": false
}
  • You can specify one or more attachments to the message. The attachment file can be uploaded along with the message using this endpoint.

  • You can also specify Structured Objects as part of the message, and use Apache FreeMarker templates with these objects. See Use Apache FreeMarker Templates section below.

  • Interactive Elements can be sent with your messages. See Sending messages with Symphony Elements section below.

  • For authentication, you must either use the sessionToken that was created for delegated application access, or both the sessionToken and keyManagerToken together.

  • When calling this as an OBO-Enabled Endpoints, use the OBO User Authenticate token for sessionToken.

🚧 Known Limitations

  • You can’t send a message that contains only an attachment without any message content. message must contain a least one space.

  • DLP (Expression Filters) only works with 1.53 version onwards.

  • Symphony Elements only works with 1.55.3 version onwards.

  • To send messages to not public rooms, the caller needs to be part of the stream.

  • To send numeric cashtags as signals, add a * before the number such as $*122450. E.g. <messageML><cash tag="*122450"/></messageML> For more information, refer to Message Format - MessageML.

  • Attachments: The limit is set to 30Mb total size; also, it is recommended not to exceed 25 files.

  • For more information on the size limits of messages, please refer to Messages under the section Messages Size Limits.

Sending messages with Symphony Elements

Symphony Elements is a collection of interactive elements that can be sent within messages to facilitate communication with Symphony users.

Through the use of the elements, bots can send messages that contain forms with text fields, dropdown menus, person selectors, buttons and more! To use the Elements, you just need to call the /agent/v4/stream/:sid/message/create API using the MessageML format. For more information and examples, refer to Symphony Elements.

Sending Symphony Elements is only supported for SYSTEM users (Service Accounts).

Use Apache FreeMarker Templates

The message and data parameters of the Create Message v4 endpoint supports using Apache FreeMarker templates with Structured Objects.

Important! To support the use of Freemarker variables, the top-level variable name in the div or span tag in <messageML> must be $entity or $data.

Using the Freemarker template, you can also create tables that contain a special column with checkboxes or buttons on it, allowing users to select one or more rows of the table. For more information, refer to Symphony Elements - Table Select.

The first and second examples show the FreeMarker template content enclosed in <messageML> for the message parameter and the associated data model for the data parameter. The third example shows the resulting PresentationML representation of the message.

See also cURL - Message + Data in the examples below.

<messageML>
	<div>Messages for user <b>${data["messageList"].user.userName}</b>:</div>
	<table>
		<#list data["messageList"].messages as msg>
		<tr>
			<td>${msg.timestamp}</td>
			<td>${msg.text}</td>
		</tr>
		</#list>
	</table>
</messageML>
{
  "messageList": {
    "version": "1.0",
    "user": {
      "id": 123456,
      "userName": "bot.user01"
    },
    "messages": [
      {
        "timestamp": "1504736061894",
        "text": "Ping"
      },
      {
        "timestamp": "1504736023993",
        "text": "Pong"
      }
    ]
  }
}
<div data-format="PresentationML" data-version="2.0">
   <div>Messages for user <b>bot.user01</b>:</div>
   <table>
      <tr>
         <td>1504736061894</td>
         <td>Ping</td>
      </tr>
      <tr>
         <td>1504736023993</td>
         <td>Pong</td>
      </tr>
   </table>
</div>

Other request examples

curl -X POST \
  https://acme.symphony.com/agent/v4/stream/xFfPil_o26qXzGwWvcw5RH___qQr0W7EdA/message/create \
  -H 'Content-Type: multipart/form-data' \
  -H 'sessionToken: SESSION_TOKEN' \
	-H 'keyManagerToken: KEY_MANAGER_TOKEN' \
  --form-string 'message=<messageML>Hello world!</messageML>'
curl -X POST \
  https://acme.symphony.com:443/agent/v4/stream/xFfPil_o26qXzGwWvcw5RH___qQr0W7EdA/message/create \
  -H 'content-type: multipart/form-data' \
  -H 'keyManagerToken: KEY_MANAGER_TOKEN' \
  -H 'sessionToken: SESSION_TOKEN' \
  --form-string 'message=<messageML>Hello world!</messageML>' \
  -F 'attachment=@image1.png' \
  -F 'attachment=@image2.png'
curl -X POST \
https://acme.symphony.com:443/agent/v4/stream/xFfPil_o26qXzGwWvcw5RH___qQr0W7EdA/message/create \
  -H 'Content-Type: multipart/form-data' \
  -H 'keyManagerToken: KEY_MANAGER_TOKEN' \
  -H 'sessionToken: SESSION_TOKEN' \
  --form-string 'message=<messageML>This is an <div class="entity" data-entity-id="object001"><b>important</b></div> message.</messageML>' \
  -F 'data={
    "object001":
    {
        "type":     "org.symphonyoss.taxonomy",
        "version":  "0.1",
        "id":
        [
            {
                "type":     "org.symphonyoss.taxonomy.keyword",
                "value":    "important"
            }
        ]
    }
}'
curl -X POST \
  https://acme.symphony.com:443/agent/v4/stream/xFfPil_o26qXzGwWvcw5RH___qQr0W7EdA/message/create \

-H "sessionToken: SESSION_TOKEN" \
-H "keyManagerToken: KEY_MANAGER_TOKEN" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "message='<messageML>Hello world</messageML>'&data='{'foo':'bar'}'"
curl -X POST \
  https://acme.symphony.com:443/agent/v4/stream/xFfPil_o26qXzGwWvcw5RH___qQr0W7EdA/message/create \

-H "sessionToken: SESSION_TOKEN" \
-H "keyManagerToken: KEY_MANAGER_TOKEN" \
-H "Content-Type: application/json" \
-d '{
        "message": "<messageML>Hello world</messageML>",
        "data": "{\"foo\":\"bar\"}"
    }'

📘 See also

Message MessageML Message ID Message Format - MessageML PresentationML Message Format - ExtensionML Colors Symphony Elements

Last updated