sinch.domains.conversation.api.v1.conversations_apis module

class sinch.domains.conversation.api.v1.conversations_apis.Conversations(sinch)[source]

Bases: BaseConversation

list(
app_id: str | None = None,
contact_id: str | None = None,
only_active: bool | None = None,
page_size: int | None = None,
page_token: str | None = None,
active_channel: Literal['WHATSAPP', 'RCS', 'SMS', 'MESSENGER', 'VIBERBM', 'MMS', 'INSTAGRAM', 'TELEGRAM', 'KAKAOTALK', 'KAKAOTALKCHAT', 'LINE', 'WECHAT', 'APPLEBC'] | Annotated[str, Strict(strict=True)] | None = None,
**kwargs,
) → Paginator[ListConversationsResponse, ConversationResponse][source]

This operation lists all conversations that are associated with an app and/or a contact. Note that either app_id or contact_id is required in order for the operation to function correctly.

Parameters:
  • app_id (Optional[str]) – (optional) The ID of the app involved in the conversations.

  • contact_id (Optional[str]) – (optional) The ID of the contact involved in the conversations.

  • only_active (Optional[bool]) – (optional) Set to True to list only active conversations, False to list only inactive ones.

  • page_size (Optional[int]) – (optional) The maximum number of conversations to fetch. The server default is 10 and the maximum is 20.

  • page_token (Optional[str]) – (optional) Next page token previously returned if any.

  • active_channel (Optional[ConversationChannelType]) – (optional) Only fetch conversations from the active_channel.

  • **kwargs –

    Additional parameters for the request.

Returns:

A paginator for iterating through the conversations.

Return type:

Paginator[ListConversationsResponse, ConversationResponse]

For detailed documentation, visit https://developers.sinch.com/docs/conversation/.

create(
app_id: str,
contact_id: str,
active: bool | None | Unset = <sinch.core.sentinel.Unset object>,
active_channel: Literal['WHATSAPP',
'RCS',
'SMS',
'MESSENGER',
'VIBERBM',
'MMS',
'INSTAGRAM',
'TELEGRAM',
'KAKAOTALK',
'KAKAOTALKCHAT',
'LINE',
'WECHAT',
'APPLEBC'] | ~typing.Annotated[str,
~pydantic.types.Strict(strict=True)] | None | ~sinch.core.sentinel.Unset = <sinch.core.sentinel.Unset object>,
metadata_json: Dict[str,
~typing.Any] | None | ~sinch.core.sentinel.Unset=<sinch.core.sentinel.Unset object>,
correlation_id: str | None | Unset = <sinch.core.sentinel.Unset object>,
**kwargs,
) → ConversationResponse[source]

Creates a new empty conversation. In Conversation mode, it is generally not needed to create a conversation explicitly since sending or receiving a message automatically creates a new conversation if it does not already exist between the given app and contact. Creating empty conversation is useful if the metadata of the conversation should be populated when the first message in the conversation is a contact message or the first message in the conversation comes out-of-band and needs to be injected with InjectMessage endpoint.

Parameters:
  • app_id (str) – (required) The ID of the participating app.

  • contact_id (str) – (required) The ID of the participating contact.

  • active (UnsetOr[Optional[bool]]) – (optional) Flag for whether this conversation is active.

  • active_channel (UnsetOr[Optional[ConversationChannelType]]) – (optional) The active channel of the conversation.

  • metadata_json (UnsetOr[Optional[Dict[str, Any]]]) – (optional) Arbitrary data set by the Conversation API clients. A valid JSON object.

  • correlation_id (UnsetOr[Optional[str]]) – (optional) Arbitrary correlation ID related to the MT message set by the Conversation API user.

  • **kwargs –

    Additional parameters for the request.

Returns:

The created conversation.

Return type:

ConversationResponse

For detailed documentation, visit https://developers.sinch.com/docs/conversation/.

get(
conversation_id: str,
**kwargs,
) → ConversationResponse[source]

Retrieves a conversation by id. A conversation has two participating entities, an app and a contact.

Parameters:
  • conversation_id (str) – (required) The unique ID of the conversation.

  • **kwargs –

    Additional parameters for the request.

Returns:

The conversation.

Return type:

ConversationResponse

For detailed documentation, visit https://developers.sinch.com/docs/conversation/.

delete(conversation_id: str, **kwargs) → None[source]

Deletes a conversation together with all the messages sent as part of the conversation.

Parameters:
  • conversation_id (str) – (required) The unique ID of the conversation.

  • **kwargs –

    Additional parameters for the request.

Returns:

None

Return type:

None

For detailed documentation, visit https://developers.sinch.com/docs/conversation/.

update(
conversation_id: str,
active: bool | None | Unset = <sinch.core.sentinel.Unset object>,
active_channel: Literal['WHATSAPP',
'RCS',
'SMS',
'MESSENGER',
'VIBERBM',
'MMS',
'INSTAGRAM',
'TELEGRAM',
'KAKAOTALK',
'KAKAOTALKCHAT',
'LINE',
'WECHAT',
'APPLEBC'] | ~typing.Annotated[str,
~pydantic.types.Strict(strict=True)] | None | ~sinch.core.sentinel.Unset = <sinch.core.sentinel.Unset object>,
app_id: str | None | Unset = <sinch.core.sentinel.Unset object>,
contact_id: str | None | Unset = <sinch.core.sentinel.Unset object>,
metadata_json: Dict[str,
~typing.Any] | None | ~sinch.core.sentinel.Unset=<sinch.core.sentinel.Unset object>,
correlation_id: str | None | Unset = <sinch.core.sentinel.Unset object>,
metadata_update_strategy: Literal['REPLACE',
'MERGE_PATCH'] | ~typing.Annotated[str,
~pydantic.types.Strict(strict=True)] | None = None,
**kwargs,
) → ConversationResponse[source]

This operation updates a conversation which can, for instance, be used to update the metadata associated with a conversation.

Omitted parameters are left untouched on the server; passing None explicitly clears the field.

Parameters:
  • conversation_id (str) – (required) The unique ID of the conversation.

  • active (UnsetOr[Optional[bool]]) – (optional) Flag for whether this conversation is active.

  • active_channel (UnsetOr[Optional[ConversationChannelType]]) – (optional) The active channel of the conversation.

  • app_id (UnsetOr[Optional[str]]) – (optional) The ID of the participating app.

  • contact_id (UnsetOr[Optional[str]]) – (optional) The ID of the participating contact.

  • metadata_json (UnsetOr[Optional[Dict[str, Any]]]) – (optional) Arbitrary data set by the Conversation API clients. A valid JSON object.

  • correlation_id (UnsetOr[Optional[str]]) – (optional) Arbitrary correlation ID related to the MT message set by the Conversation API user.

  • metadata_update_strategy (Optional[MetadataUpdateStrategyType]) – (optional) Update strategy for the conversation_metadata field. The server default is REPLACE.

  • **kwargs –

    Additional parameters for the request.

Returns:

The updated conversation.

Return type:

ConversationResponse

For detailed documentation, visit https://developers.sinch.com/docs/conversation/.

list_recent(
app_id: str,
only_active: bool | None = None,
page_size: int | None = None,
page_token: str | None = None,
order: Literal['ASC', 'DESC'] | str | None = None,
**kwargs,
) → Paginator[ListRecentConversationsResponse, RecentConversationResponse][source]

This operation lists conversations and their most recent message, ordered by when the most recent message was sent for that conversation.

Parameters:
  • app_id (str) – (required) The application ID.

  • only_active (Optional[bool]) – (optional) True if only active conversations should be listed. The server default is False.

  • page_size (Optional[int]) – (optional) The maximum number of conversations to fetch. The server default is 10 and the maximum value is 50.

  • page_token (Optional[str]) – (optional) Next page token previously returned if any.

  • order (Optional[Union[Literal["ASC", "DESC"], str]]) – (optional) Whether to sort conversations by newest message first (DESC) or oldest (ASC). The server default is DESC.

  • **kwargs –

    Additional parameters for the request.

Returns:

A paginator for iterating through the recent conversations.

Return type:

Paginator[ListRecentConversationsResponse, RecentConversationResponse]

For detailed documentation, visit https://developers.sinch.com/docs/conversation/.

stop_active(conversation_id: str, **kwargs) → None[source]

This operation stops the referenced conversation, if the conversation is still active. In Conversation mode, a new conversation will be created if a new message is exchanged between the app or contact that was part of the stopped conversation.

Parameters:
  • conversation_id (str) – (required) The unique ID of the conversation.

  • **kwargs –

    Additional parameters for the request.

Returns:

None

Return type:

None

For detailed documentation, visit https://developers.sinch.com/docs/conversation/.

inject_message(conversation_id: str, contact_id: str, channel_identity: ~sinch.domains.conversation.models.v1.types.channel_identity_dict.ChannelIdentityDict, direction: ~typing.Literal['TO_APP', 'TO_CONTACT'] | ~typing.Annotated[str, ~pydantic.types.Strict(strict=True)], accept_time: ~datetime.datetime, app_message: ~sinch.domains.conversation.models.v1.messages.types.app_message_dict.AppMessageDict | ~sinch.core.sentinel.Unset = <sinch.core.sentinel.Unset object>, contact_message: ~sinch.domains.conversation.models.v1.messages.types.contact_message_dict.ContactMessageDict | ~sinch.core.sentinel.Unset = <sinch.core.sentinel.Unset object>, sender_id: str | None | ~sinch.core.sentinel.Unset = <sinch.core.sentinel.Unset object>, processing_mode: ~typing.Literal['CONVERSATION', 'DISPATCH'] | ~typing.Annotated[str, ~pydantic.types.Strict(strict=True)] | None | ~sinch.core.sentinel.Unset = <sinch.core.sentinel.Unset object>, metadata: str | None | ~sinch.core.sentinel.Unset = <sinch.core.sentinel.Unset object>, **kwargs) → None[source]

This operation injects a conversation message in to a specific conversation.

Set exactly one of app_message or contact_message; otherwise a ValueError is raised.

Parameters:
  • conversation_id (str) – (required) The ID of the conversation.

  • contact_id (str) – (required) The ID of the contact registered in the conversation provided.

  • channel_identity (ChannelIdentityDict) – (required) The channel identity of the contact.

  • direction (ConversationDirectionType) – (required) The direction of the message flow: TO_APP or TO_CONTACT.

  • accept_time (datetime) – (required) The processed time of the message in UTC timezone. Must be less than current_time and greater than (current_time - 30 days).

  • app_message (UnsetOr[AppMessageDict]) – (optional) A message originating from a Conversation API app.

  • contact_message (UnsetOr[ContactMessageDict]) – (optional) A message originating from a contact.

  • sender_id (UnsetOr[Optional[str]]) – (optional) For Contact Messages (MO messages), the sender ID represents the recipient to which the message was sent.

  • processing_mode (UnsetOr[Optional[ProcessingModeType]]) – (optional) Whether or not Conversation API should store contacts and conversations for the app.

  • metadata (UnsetOr[Optional[str]]) – (optional) Metadata associated with the contact. Up to 1024 characters long.

  • **kwargs –

    Additional parameters for the request.

Returns:

None

Return type:

None

For detailed documentation, visit https://developers.sinch.com/docs/conversation/.

inject_event(
conversation_id: str,
app_event: AppEventDict,
accept_time: datetime,
contact_id: str | None | Unset = <sinch.core.sentinel.Unset object>,
channel_identity: ChannelIdentityDict | None | Unset = <sinch.core.sentinel.Unset object>,
processing_mode: Literal['CONVERSATION',
'DISPATCH'] | ~typing.Annotated[str,
~pydantic.types.Strict(strict=True)] | None | ~sinch.core.sentinel.Unset = <sinch.core.sentinel.Unset object>,
**kwargs,
) → InjectEventResponse[source]

This operation injects a conversation event in to a specific conversation. It only supports injecting App events in CONVERSATION mode.

Parameters:
  • conversation_id (str) – (required) The unique ID of the conversation.

  • app_event (AppEventDict) – (required) The event originating from an app. Set exactly one event type key.

  • accept_time (datetime) – (required) The processed time of the event in UTC timezone. Must be less than current_time and greater than (current_time - 30 days).

  • contact_id (UnsetOr[Optional[str]]) – (optional) The ID of the contact.

  • channel_identity (UnsetOr[Optional[ChannelIdentityDict]]) – (optional) The channel identity of the contact.

  • processing_mode (UnsetOr[Optional[ProcessingModeType]]) – (optional) Whether or not Conversation API should store contacts and conversations for the app.

  • **kwargs –

    Additional parameters for the request.

Returns:

The ID and accepted time of the injected event.

Return type:

InjectEventResponse

For detailed documentation, visit https://developers.sinch.com/docs/conversation/.