symphony.bdk.core.service.message.message_service.MessageService#

class symphony.bdk.core.service.message.message_service.MessageService(messages_api: symphony.bdk.core.service.message.multi_attachments_messages_api.MultiAttachmentsMessagesApi, message_api: symphony.bdk.gen.pod_api.message_api.MessageApi, message_suppression_api: symphony.bdk.gen.pod_api.message_suppression_api.MessageSuppressionApi, streams_api: symphony.bdk.gen.pod_api.streams_api.StreamsApi, pod_api: symphony.bdk.gen.pod_api.pod_api.PodApi, attachment_api: symphony.bdk.gen.agent_api.attachments_api.AttachmentsApi, default_api: symphony.bdk.gen.pod_api.default_api.DefaultApi, auth_session: symphony.bdk.core.auth.auth_session.AuthSession, retry_config: symphony.bdk.core.config.model.bdk_retry_config.BdkRetryConfig)#

Bases: symphony.bdk.core.service.message.message_service.OboMessageService

Service class for managing messages.

__init__(messages_api: symphony.bdk.core.service.message.multi_attachments_messages_api.MultiAttachmentsMessagesApi, message_api: symphony.bdk.gen.pod_api.message_api.MessageApi, message_suppression_api: symphony.bdk.gen.pod_api.message_suppression_api.MessageSuppressionApi, streams_api: symphony.bdk.gen.pod_api.streams_api.StreamsApi, pod_api: symphony.bdk.gen.pod_api.pod_api.PodApi, attachment_api: symphony.bdk.gen.agent_api.attachments_api.AttachmentsApi, default_api: symphony.bdk.gen.pod_api.default_api.DefaultApi, auth_session: symphony.bdk.core.auth.auth_session.AuthSession, retry_config: symphony.bdk.core.config.model.bdk_retry_config.BdkRetryConfig)#

Methods

__init__(messages_api, message_api, ...)

blast_message(stream_ids, message[, data, ...])

Send a message to multiple existing streams.

get_attachment(stream_id, message_id, ...)

Downloads the attachment body by the stream ID, message ID and attachment ID.

get_attachment_types()

Retrieves a list of supported file extensions for attachments.

get_message(message_id)

Retrieves the details of a message given its message ID.

get_message_relationships(message_id)

Gets the message metadata relationship.

get_message_status(message_id)

Get the status of a particular message, i.e the list of users who the message was sent to, delivered to and the list of users who read the message.

import_messages(messages)

Imports a list of messages to Symphony.

list_attachments(stream_id[, since, to, ...])

List attachments in a particular stream.

list_message_receipts(message_id)

Fetches receipts details from a specific message.

list_messages(stream_id[, since, skip, limit])

Get messages from an existing stream.

search_all_messages(query[, sort_dir, ...])

Searches for messages in the context of a specified user, given an argument-based query.

search_messages(query[, sort_dir, skip, limit])

Searches for messages in the context of a specified user, given an argument-based query and pagination attributes (skip and limit parameters).

send_message(stream_id, message[, data, ...])

Send a message to an existing stream.

suppress_message(message_id)

Suppresses a message, preventing its contents from being displayed to users.

update_message(stream_id, message_id, message)

Update an existing message.

async blast_message(stream_ids: List[str], message: Union[str, symphony.bdk.core.service.message.model.Message], data=None, version: str = '', attachment: Optional[List[Union[IO, Tuple[IO, IO]]]] = None) symphony.bdk.gen.agent_model.v4_message_blast_response.V4MessageBlastResponse#

Send a message to multiple existing streams. See: Blast Message

Parameters
  • stream_ids – The list of stream IDs to send the message to

  • message – a Message instance or a string containing the MessageML content to be sent. If it is a Message instance, other parameters will be ignored. If it is a string, <messageML> tags can be omitted.

  • data – an object (e.g. dict) that will be serialized into JSON using json.dumps.

  • version – Optional message version in the format “major.minor”. If empty, defaults to the latest supported version.

  • attachment – One or more files (opened in binary or text mode) to be sent along with the message. Elements of the list can be attachment files or tuples of (attachment, preview). If one attachment has a preview, then all attachments must have a preview. The limit is set to 30Mb total size; also, it is recommended not to exceed 25 files.

Returns

async get_attachment(stream_id: str, message_id: str, attachment_id: str) str#

Downloads the attachment body by the stream ID, message ID and attachment ID. See: Attachment

Parameters
  • stream_id – The stream ID where to look for the attachment.

  • message_id – The ID of the message containing the attachment.

  • attachment_id – The ID of the attachment

Returns

a byte array of attachment encoded in base 64.

get_attachment_types() List[str]#

Retrieves a list of supported file extensions for attachments. See: Attachment Types

Returns

a list of String containing all allowed file extensions for attachments.

get_message(message_id: str) symphony.bdk.gen.agent_model.v4_message.V4Message#

Retrieves the details of a message given its message ID. See: Get Message

Parameters

message_id – MessageId the ID of the message to be retrieved.

Returns

a V4Message containing the message’s details.

get_message_relationships(message_id: str) symphony.bdk.gen.pod_model.message_metadata_response.MessageMetadataResponse#

Gets the message metadata relationship. This API allows users to track the relationship between a message and all the forwards and replies of that message. See: Message Metadata

Parameters

message_id – the ID of the message to get relationships from.

Returns

a MessageMetadataResponse object holding information about the current message relationships (parent, replies, forwards and form replies).

async get_message_status(message_id: str) symphony.bdk.gen.pod_model.message_status.MessageStatus#

Get the status of a particular message, i.e the list of users who the message was sent to, delivered to and the list of users who read the message. See: Message Status

Parameters

message_id – MessageId the ID of the message to be checked

Returns

Status of the given message

import_messages(messages: List[symphony.bdk.gen.agent_model.v4_imported_message.V4ImportedMessage]) [<class 'symphony.bdk.gen.agent_model.v4_import_response.V4ImportResponse'>]#

Imports a list of messages to Symphony. See: Import Message

Parameters

messages – List of messages to import.

Returns

The list of imported messages

list_attachments(stream_id: str, since: int = None, to: int = None, limit: int = 50, sort_dir: str = 'ASC') List[symphony.bdk.gen.pod_model.stream_attachment_item.StreamAttachmentItem]#

List attachments in a particular stream. See: List Attachments

Parameters
  • stream_id – The stream ID where to look for the attachments

  • since – Timestamp of the first required attachment.

  • to – Timestamp of the last required attachment.

  • limit – Maximum number of attachments to return. This optional value defaults to 50 and should be between 0 and 100.

  • sort_dir – Attachment date sort direction : ASC or DESC. Default: ASC.

Returns

the list of attachments in the stream.

list_message_receipts(message_id: str) symphony.bdk.gen.pod_model.message_receipt_detail_response.MessageReceiptDetailResponse#

Fetches receipts details from a specific message. See: List Message Receipts

Parameters

message_id – MessageId the ID of the message to get receipt details from.

:return:a MessageReceiptDetailResponse object holding all receipt information.

list_messages(stream_id: str, since: int = 0, skip: int = 0, limit: int = 50) [<class 'symphony.bdk.gen.agent_model.v4_message.V4Message'>]#

Get messages from an existing stream. Additionally returns any attachments associated with the message. See: Messages

Parameters
  • stream_id – The stream where to look for messages

  • since – Timestamp of the earliest possible date of the first message returned.

  • skip – Number of messages to skip. Default: 0

  • limit – Maximum number of messages to return. Default: 50

Returns

the list of matching messages in the stream.

async search_all_messages(query: symphony.bdk.gen.agent_model.message_search_query.MessageSearchQuery, sort_dir: str = 'desc', chunk_size: int = 50, max_number: Optional[int] = None) AsyncGenerator[symphony.bdk.gen.agent_model.v4_message.V4Message, None]#

Searches for messages in the context of a specified user, given an argument-based query. See: Message Search (using POST)

Parameters
  • query – The search query arguments

  • sort_dir – Sorting direction for response. Possible values are desc (default) and asc.

  • chunk_size – the maximum number of elements to retrieve in one underlying HTTP call

  • max_number – the total maximum number of elements to retrieve

Returns

an asynchronous generator of matching messages

search_messages(query: symphony.bdk.gen.agent_model.message_search_query.MessageSearchQuery, sort_dir: str = 'desc', skip: int = 0, limit: int = 50) List[symphony.bdk.gen.agent_model.v4_message.V4Message]#

Searches for messages in the context of a specified user, given an argument-based query and pagination attributes (skip and limit parameters). See: Message Search (using POST)

Parameters
  • query – The search query arguments

  • sort_dir – Sorting direction for response. Possible values are desc (default) and asc.

  • skip – Number of messages to skip. Default: 0

  • limit – Maximum number of messages to return. Default: 50

Returns

The list of matching messages in the stream

async send_message(stream_id: str, message: Union[str, symphony.bdk.core.service.message.model.Message], data=None, version: str = '', attachment: Optional[List[Union[IO, Tuple[IO, IO]]]] = None) symphony.bdk.gen.agent_model.v4_message.V4Message#

Send a message to an existing stream. See: Create Message

Parameters
  • stream_id – The ID of the stream to send the message to.

  • message – a Message instance or a string containing the MessageML content to be sent. If it is a Message instance, other parameters will be ignored. If it is a string, <messageML> tags can be omitted.

  • data – an object (e.g. dict) that will be serialized into JSON using json.dumps.

  • version – Optional message version in the format “major.minor”. If empty, defaults to the latest supported version.

  • attachment – One or more files (opened in binary or text mode) to be sent along with the message. Elements of the list can be attachment files or tuples of (attachment, preview). If one attachment has a preview, then all attachments must have a preview. The limit is set to 30Mb total size; also, it is recommended not to exceed 25 files.

Returns

a V4Message object containing the details of the sent message.

suppress_message(message_id: str) symphony.bdk.gen.pod_model.message_suppression_response.MessageSuppressionResponse#

Suppresses a message, preventing its contents from being displayed to users. See: Suppress Message

Parameters

message_id – Message ID of the message to be suppressed.

Returns

a MessageSuppressionResponse instance containing information about the message suppression.

update_message(stream_id: str, message_id: str, message: Union[str, symphony.bdk.core.service.message.model.Message], data=None, version: str = '', silent=True) symphony.bdk.gen.agent_model.v4_message.V4Message#

Update an existing message. The existing message must be a valid social message, that has not been deleted. See: Update Message

Parameters
  • stream_id – The ID of the stream where the message is being updated.

  • message_id – The ID of the message that is being updated.

  • message – a Message instance or a string containing the MessageML content to be sent. If it is a Message instance, other parameters will be ignored. If it is a string, <messageML> tags can be omitted.

  • data – an object (e.g. dict) that will be serialized into JSON using json.dumps.

  • silent – a bool flag that will determine if the updated message is going to be marked as read (when true, which is default value) or unread (when false).

  • version – Optional message version in the format “major.minor”. If empty, defaults to the latest supported version.

Returns

a V4Message object containing the details of the updated message.