Skip to content
FacebookYouTubeX (Twitter)

Messages

You can use the API to get the message information.

FieldTypeDescription
idStringThe unique identifier for the message which is given by Pingstreams.
senderStringA unique identifier of the sender. It can be: the user identifier, a bot identifier or the system user
senderFullnameStringThe sender fullname. It can be: the user fullname, the bot name or an alias
recipientStringA unique identifier of the recipient. It can be: the request_id field (external id) of the request
statusNumberThe message status: FAILED : -100, SENDING : 0, SENT : 100, DELIVERED : 150, RECEIVED : 200, RETURN_RECEIPT: 250, SEEN : 300
textStringThe message text.
typeStringThe message type. Accepted values: text (default), image
metadataObjectThe message metadata.
attributesObjectThe custom attributes which are set for the message.
createdAtStringThe time (ISO-8601 date string) when the message was created.
updatedAtStringThe time (ISO-8601 date string) when the message was updated.
createdByStringThe unique identifier of the row creator
id_projectStringThe unique identifier of the project

POST https://api.pingstreams.com/v3/:project_id/requests/:request_id/messages

Allows to send a message. This method also creates a new conversation (request) if it didn’t exist at the time of the call.

ParameterTypeDescription
project_idstringThe project_id is a unique code assigned to your project when you create it in Pingstreams
request_idstringThe request identifier. Must follow this pattern ‘support-group-UUID’
HeaderTypeDescription
Authorizationstringauthorization token. Basic Auth or JWT
Content-Typestringuse “application/json” value
FieldTypeDescription
textstringthe message text
departmentidstringThe selected department identifier. Accepted only on the first message.
sourcePagestringThe source page of the request. Accepted only on the first message.
languagestringThe language of the request. Accepted only on the first message.
userAgentstringThe userAgent string of the request. Accepted only on the first message.
attributesobjectit’s the message custom attributes. Example: attributes = {"custom_attribute1": "value1"}. You can also use attributes to enable advanced features.
typestringit’s the message type. “text” value for textual message and “image” for sending image message(you must set metadata field). Available values: text (default) and image.
metadataobjectit’s the image properties: src is the absolute source path of the image, width is the image width, height is the image height. Width and height are optional. Example: metadata = { "src": "https://www.pingstreams.com/wp-content/uploads/2018/03/pingstreams-logo.png", "width": 200, "height": 200 }
{
"_id":"5c81593adf767b0017d1aa68",
"updatedAt":"2019-03-07T17:47:38.411Z",
"createdAt":"2019-03-07T17:47:38.411Z",
"sender":"SRbb2PfbSFcgICv9VQBcURZeloh1",
"senderFullname":"Guest",
"recipient":"support-group-L_OG76RYhR0XFiMf2PK",
"text":"hello from api",
"id_project":"5b55e806c93dde00143163dd",
"createdBy":"SRbb2PfbSFcgICv9VQBcURZeloh1",
"__v":0,
"status":200
}
curl -v -X POST -H 'Content-Type: application/json' -u user@example.com:123456 -d '{"text":"hello from api"}' https://api.pingstreams.com/v3/5b55e806c93dde00143163dd/requests/support-group-1234/messages
curl -v -X POST -H 'Content-Type: application/json' -u user@example.com:123456 -d '{"text":"Alternative text from api", "type":"image", "metadata": {"src": "https://pingstreams.com/pingstreams-logo-x1.png", "width": 200, "height": 200}}' https://api.pingstreams.com/v3/5b55e806c93dde00143163dd/requests/support-group-1234/messages

When you send a message you can use the following attributes to activate advanced features:

  • attributes.clienttimestamp: use this property to force the message timestamp in milliseconds. This parameter is used by the clients (widgets and chat agents) to perform a client side reordering of messages based on the value of the timestamp field. This property doesn’t guarantees the order of arrival, but only the ordering or reordering on the client side.
  • attributes.attachment: use this property to set the response additional reply componenst as quick replies, buttons, links etc. (see: https://developer.pingstreams.com/widget/advanced/widget-json-protocol)
  • attributes.subtype.info: If “true” it hides the message to the end-user channels (Widget, whatsapp, Telegram, Facebook etc.)
  • attributes.microlanguage: set this property to true to enable the microlanguage pre-processor. You can find more info here: Chatbot buttons, images, video and microlanguage example
  • attributes.disableInputMessage: if true it disables the input message, until the next message arrival
  • attributes.inputMessagePlaceholder: if set, it modify the default input text placeholder
  • attributes.updateUserEmail and attributes.updateUserFullname: If set, the back forward user fullname and email to the widget. Useful if you set user fullname or email in a webhook or external service.

Pingstreams uses Chat21 as messaging engine. When you send a message to Pingstreams using the REST API, Pingstreams will forward the call to the Chat21 REST API. You can see how the Chat21 REST Api works here: https://github.com/chat21/chat21-cloud-functions/blob/master/docs/api.md#send-a-message

You can enable special message features following this paragraph: https://github.com/chat21/chat21-cloud-functions/blob/master/docs/api.md#message-attributes

GET https://api.pingstreams.com/v3/:project_id/requests/:request_id/messages

Fetches the messages by his or her request_id

ParameterTypeDescription
request_idstringthe request_id field. It’s the external request identifier.
project_idstringthe Project Id is a unique code assigned to your project when you create it in Pingstreams.
HeaderTypeDescription
Authorizationstringauthorization token. Basic Auth or JWT
[
{
"_id":"5c81593adf767b0017d1aa68",
"updatedAt":"2019-03-07T17:47:38.411Z",
"createdAt":"2019-03-07T17:47:38.411Z",
"sender":"SRbb2PfbSFcgICv9VQBcURZeloh1",
"senderFullname":"Guest",
"recipient":"support-group-L_OG76RYhR0XFiMf2PK",
"text":"test56",
"id_project":"5b55e806c93dde00143163dd",
"createdBy":"SRbb2PfbSFcgICv9VQBcURZeloh1",
"__v":0,
"status":200
},
{
"_id":"5c81593adf767b0017d1aa69",
"updatedAt":"2019-03-07T17:47:38.625Z",
"createdAt":"2019-03-07T17:47:38.625Z",
"sender":"system",
"senderFullname":"Bot",
"recipient":"support-group-L_OG76RYhR0XFiMf2PK",
"text":"La stiamo mettendo in contatto con un operatore. Attenda...",
"id_project":"5b55e806c93dde00143163dd",
"createdBy":"system",
"__v":0,
"status":200
}
]
curl -v -X GET -u user@example.com:123456 https://api.pingstreams.com/v3/5b55e806c93dde00143163dd/requests/support-group-L_OG76RYhR0XFiMf2PK/messages

Get the message by request id and message id

Section titled “Get the message by request id and message id”

GET https://api.pingstreams.com/v3/:project_id/requests/:request_id/messages/:message_id

Fetche the message by his or her id

ParameterTypeDescription
request_idstringthe request_id field. It’s the external request identifier.
message_idstringthe message identifier
project_idstringthe Project Id is a unique code assigned to your project when you create it in Pingstreams.
HeaderTypeDescription
Authorizationstringauthorization token. Basic Auth or JWT
{
"_id":"5c81593adf767b0017d1aa68",
"updatedAt":"2019-03-07T17:47:38.411Z",
"createdAt":"2019-03-07T17:47:38.411Z",
"sender":"SRbb2PfbSFcgICv9VQBcURZeloh1",
"senderFullname":"Guest",
"recipient":"support-group-L_OG76RYhR0XFiMf2PK",
"text":"test56",
"id_project":"5b55e806c93dde00143163dd",
"createdBy":"SRbb2PfbSFcgICv9VQBcURZeloh1",
"__v":0,
"status":200
}
curl -v -X GET -u user@example.com:123456 https://api.pingstreams.com/v3/5b55e806c93dde00143163dd/requests/support-group-L_OG76RYhR0XFiMf2PK/messages/5c81593adf767b0017d1aa68

POST https://api.pingstreams.com/v3/:project_id/requests/:request_id/messages/multi

This method should be used for mass importing of messages. For common cases, use Send message REST API

ParameterTypeDescription
project_idstringThe project_id is a unique code assigned to your project when you create it in Pingstreams
request_idstringThe request identifier. Must follow this pattern ‘support-group-UUID’
HeaderTypeDescription
Authorizationstringauthorization token. Basic Auth or JWT
Content-Typestringuse “application/json” value
FieldTypeDescription
textstringthe message text
attributesobjectit’s the message custom attributes. Example: attributes = {"custom_attribute1": "value1"}. You can also use attributes to enable advanced features.
typestringit’s the message type. “text” value for textual message and “image” for sending image message(you must set metadata field). Available values: text (default) and image.
metadataobjectit’s the image properties: src is the absolute source path of the image, width is the image width, height is the image height. Width and height are optional. Example: metadata = { "src": "https://www.pingstreams.com/wp-content/uploads/2018/03/pingstreams-logo.png", "width": 200, "height": 200 }
{
"_id":"5c81593adf767b0017d1aa68",
"updatedAt":"2019-03-07T17:47:38.411Z",
"createdAt":"2019-03-07T17:47:38.411Z",
"sender":"SRbb2PfbSFcgICv9VQBcURZeloh1",
"senderFullname":"Guest",
"recipient":"support-group-L_OG76RYhR0XFiMf2PK",
"text":"hello from api",
"id_project":"5b55e806c93dde00143163dd",
"createdBy":"SRbb2PfbSFcgICv9VQBcURZeloh1",
"__v":0,
"status":200
}
curl -v -X POST -H 'Content-Type: application/json' -u user@example.com:123456 -d '[{"sender":"bb0d809b-b093-419b-8b48-11a192cc3619","text":"1"},{"sender":"bb0d809b-b093-419b-8b48-11a192cc3619", "text":"2"}]' https://api.pingstreams.com/v3/5b55e806c93dde00143163dd/requests/support-group-1234/messages/multi