# This file was auto-generated by Fern from our API Definition.

from __future__ import annotations

import typing

from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ...core.request_options import RequestOptions
from ...types.conversation_initiation_source import ConversationInitiationSource
from ...types.conversation_product import ConversationProduct
from ...types.conversation_signed_url_response_model import ConversationSignedUrlResponseModel
from ...types.evaluation_success_result import EvaluationSuccessResult
from ...types.get_conversation_response_model import GetConversationResponseModel
from ...types.get_conversations_page_response_model import GetConversationsPageResponseModel
from ...types.get_sip_log_messages_response import GetSipLogMessagesResponse
from ...types.token_response_model import TokenResponseModel
from .raw_client import AsyncRawConversationsClient, RawConversationsClient
from .types.conversations_get_request_format import ConversationsGetRequestFormat
from .types.conversations_list_request_exclude_statuses_item import ConversationsListRequestExcludeStatusesItem
from .types.conversations_list_request_summary_mode import ConversationsListRequestSummaryMode

if typing.TYPE_CHECKING:
    from .analysis.client import AnalysisClient, AsyncAnalysisClient
    from .audio.client import AsyncAudioClient, AudioClient
    from .feedback.client import AsyncFeedbackClient, FeedbackClient
    from .files.client import AsyncFilesClient, FilesClient
    from .messages.client import AsyncMessagesClient, MessagesClient
    from .tags.client import AsyncTagsClient, TagsClient
    from .topics.client import AsyncTopicsClient, TopicsClient


class ConversationsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawConversationsClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._audio: typing.Optional[AudioClient] = None
        self._feedback: typing.Optional[FeedbackClient] = None
        self._messages: typing.Optional[MessagesClient] = None
        self._tags: typing.Optional[TagsClient] = None
        self._files: typing.Optional[FilesClient] = None
        self._topics: typing.Optional[TopicsClient] = None
        self._analysis: typing.Optional[AnalysisClient] = None

    @property
    def with_raw_response(self) -> RawConversationsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawConversationsClient
        """
        return self._raw_client

    def get_signed_url(
        self,
        *,
        agent_id: str,
        include_conversation_id: typing.Optional[bool] = None,
        branch_id: typing.Optional[str] = None,
        environment: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ConversationSignedUrlResponseModel:
        """
        Get a signed url to start a conversation with an agent with an agent that requires authorization

        Parameters
        ----------
        agent_id : str
            Agent id (agent_…) or speech engine external id (seng_), resolved to the same underlying resource.

        include_conversation_id : typing.Optional[bool]
            Whether to include a conversation_id with the response. If included, the conversation_signature cannot be used again.

        branch_id : typing.Optional[str]
            The ID of the branch to use

        environment : typing.Optional[str]
            The environment to use for resolving environment variables (e.g. 'production', 'staging'). Defaults to 'production'.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ConversationSignedUrlResponseModel
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.get_signed_url(
            agent_id="agent_3701k3ttaq12ewp8b7qv5rfyszkz",
            include_conversation_id=True,
            branch_id="branch_id",
            environment="environment",
        )
        """
        _response = self._raw_client.get_signed_url(
            agent_id=agent_id,
            include_conversation_id=include_conversation_id,
            branch_id=branch_id,
            environment=environment,
            request_options=request_options,
        )
        return _response.data

    def get_webrtc_token(
        self,
        *,
        agent_id: str,
        participant_name: typing.Optional[str] = None,
        branch_id: typing.Optional[str] = None,
        environment: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TokenResponseModel:
        """
        Get a WebRTC session token for real-time communication.

        Parameters
        ----------
        agent_id : str
            Agent id (agent_…) or speech engine external id (seng_), resolved to the same underlying resource.

        participant_name : typing.Optional[str]
            Optional custom participant name. If not provided, user ID will be used

        branch_id : typing.Optional[str]
            The ID of the branch to use

        environment : typing.Optional[str]
            The environment to use for resolving environment variables (e.g. 'production', 'staging'). Defaults to 'production'.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        TokenResponseModel
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.get_webrtc_token(
            agent_id="agent_3701k3ttaq12ewp8b7qv5rfyszkz",
            participant_name="participant_name",
            branch_id="branch_id",
            environment="environment",
        )
        """
        _response = self._raw_client.get_webrtc_token(
            agent_id=agent_id,
            participant_name=participant_name,
            branch_id=branch_id,
            environment=environment,
            request_options=request_options,
        )
        return _response.data

    def list(
        self,
        *,
        cursor: typing.Optional[str] = None,
        agent_id: typing.Optional[str] = None,
        visited_agent_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        visited_agent_branch_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        call_successful: typing.Optional[EvaluationSuccessResult] = None,
        call_start_before_unix: typing.Optional[int] = None,
        call_start_after_unix: typing.Optional[int] = None,
        call_duration_min_secs: typing.Optional[int] = None,
        call_duration_max_secs: typing.Optional[int] = None,
        rating_max: typing.Optional[int] = None,
        rating_min: typing.Optional[int] = None,
        has_feedback_comment: typing.Optional[bool] = None,
        user_id: typing.Optional[str] = None,
        evaluation_params: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        data_collection_params: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        data_collection_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        evaluation_criteria_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        tool_names: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        tool_names_successful: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        tool_names_errored: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        main_languages: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        page_size: typing.Optional[int] = None,
        summary_mode: typing.Optional[ConversationsListRequestSummaryMode] = None,
        search: typing.Optional[str] = None,
        conversation_initiation_source: typing.Optional[ConversationInitiationSource] = None,
        text_only: typing.Optional[bool] = None,
        conversation_product_type: typing.Optional[ConversationProduct] = None,
        branch_id: typing.Optional[str] = None,
        version_id: typing.Optional[str] = None,
        topic_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        exclude_statuses: typing.Optional[
            typing.Union[
                ConversationsListRequestExcludeStatusesItem,
                typing.Sequence[ConversationsListRequestExcludeStatusesItem],
            ]
        ] = None,
        tag_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        workflow_node_entered_id: typing.Optional[str] = None,
        termination_reasons: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetConversationsPageResponseModel:
        """
        Get all conversations of agents that user owns. With option to restrict to a specific agent.

        Parameters
        ----------
        cursor : typing.Optional[str]
            Used for fetching next page. Cursor is returned in the response.

        agent_id : typing.Optional[str]
            Agent id (agent_…) or speech engine external id (seng_), resolved to the same underlying resource.

        visited_agent_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations where any of these agents participated. Can not exceed 50 values.

        visited_agent_branch_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations where any of these agent branches participated. Can not exceed 50 values.

        call_successful : typing.Optional[EvaluationSuccessResult]
            The result of the success evaluation

        call_start_before_unix : typing.Optional[int]
            Unix timestamp (in seconds) to filter conversations up to this start date.

        call_start_after_unix : typing.Optional[int]
            Unix timestamp (in seconds) to filter conversations after to this start date.

        call_duration_min_secs : typing.Optional[int]
            Minimum call duration in seconds.

        call_duration_max_secs : typing.Optional[int]
            Maximum call duration in seconds.

        rating_max : typing.Optional[int]
            Maximum overall rating (1-5).

        rating_min : typing.Optional[int]
            Minimum overall rating (1-5).

        has_feedback_comment : typing.Optional[bool]
            Filter conversations with user feedback comments.

        user_id : typing.Optional[str]
            Filter conversations by the user ID who initiated them.

        evaluation_params : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Evaluation filters. Repeat param. Format: criteria_id:result. Example: eval=value_framing:success

        data_collection_params : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Data collection filters. Repeat param. Format: id:op:value where op is one of eq|neq|gt|gte|lt|lte|in|exists|missing. For in, pipe-delimit values.

        data_collection_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Data collection field IDs to include in each conversation summary. Repeat param. When omitted, data_collection_results is not returned.

        evaluation_criteria_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Evaluation criteria IDs to include in each conversation summary. Repeat param. When omitted, evaluation_criteria_results is not returned.

        tool_names : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations by tool names used during the call.

        tool_names_successful : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations by tool names that had successful calls.

        tool_names_errored : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations by tool names that had errored calls.

        main_languages : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations by detected main language (language code).

        page_size : typing.Optional[int]
            How many conversations to return at maximum. Can not exceed 100, defaults to 30.

        summary_mode : typing.Optional[ConversationsListRequestSummaryMode]
            Whether to include transcript summaries in the response.

        search : typing.Optional[str]
            Full-text or fuzzy search over transcript messages

        conversation_initiation_source : typing.Optional[ConversationInitiationSource]

        text_only : typing.Optional[bool]

        conversation_product_type : typing.Optional[ConversationProduct]
            Restrict results to a single conversation product surface.

        branch_id : typing.Optional[str]
            Filter conversations by branch ID.

        version_id : typing.Optional[str]
            Filter conversations by version ID.

        topic_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations by topic IDs assigned during topic discovery.

        exclude_statuses : typing.Optional[typing.Union[ConversationsListRequestExcludeStatusesItem, typing.Sequence[ConversationsListRequestExcludeStatusesItem]]]
            Exclude conversations with the given statuses. Useful for hiding in-progress / processing conversations from list views.

        tag_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations by conversation tag IDs assigned via the conversation-tags endpoints.

        workflow_node_entered_id : typing.Optional[str]
            Filter conversations to only those that entered the given node.

        termination_reasons : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations by their stored termination_reason (metadata.termination_reason). Repeat param to match any of several.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetConversationsPageResponseModel
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.list(
            cursor="cursor",
            agent_id="agent_id",
            visited_agent_ids=["visited_agent_ids"],
            visited_agent_branch_ids=["visited_agent_branch_ids"],
            call_successful="success",
            call_start_before_unix=1,
            call_start_after_unix=1,
            call_duration_min_secs=1,
            call_duration_max_secs=1,
            rating_max=1,
            rating_min=1,
            has_feedback_comment=True,
            user_id="user_id",
            evaluation_params=["evaluation_params"],
            data_collection_params=["data_collection_params"],
            data_collection_ids=["data_collection_ids"],
            evaluation_criteria_ids=["evaluation_criteria_ids"],
            tool_names=["tool_names"],
            tool_names_successful=["tool_names_successful"],
            tool_names_errored=["tool_names_errored"],
            main_languages=["main_languages"],
            page_size=1,
            summary_mode="exclude",
            search="search",
            conversation_initiation_source="unknown",
            text_only=True,
            conversation_product_type="agents",
            branch_id="branch_id",
            version_id="version_id",
            topic_ids=["topic_ids"],
            exclude_statuses=["initiated"],
            tag_ids=["tag_ids"],
            workflow_node_entered_id="workflow_node_entered_id",
            termination_reasons=["termination_reasons"],
        )
        """
        _response = self._raw_client.list(
            cursor=cursor,
            agent_id=agent_id,
            visited_agent_ids=visited_agent_ids,
            visited_agent_branch_ids=visited_agent_branch_ids,
            call_successful=call_successful,
            call_start_before_unix=call_start_before_unix,
            call_start_after_unix=call_start_after_unix,
            call_duration_min_secs=call_duration_min_secs,
            call_duration_max_secs=call_duration_max_secs,
            rating_max=rating_max,
            rating_min=rating_min,
            has_feedback_comment=has_feedback_comment,
            user_id=user_id,
            evaluation_params=evaluation_params,
            data_collection_params=data_collection_params,
            data_collection_ids=data_collection_ids,
            evaluation_criteria_ids=evaluation_criteria_ids,
            tool_names=tool_names,
            tool_names_successful=tool_names_successful,
            tool_names_errored=tool_names_errored,
            main_languages=main_languages,
            page_size=page_size,
            summary_mode=summary_mode,
            search=search,
            conversation_initiation_source=conversation_initiation_source,
            text_only=text_only,
            conversation_product_type=conversation_product_type,
            branch_id=branch_id,
            version_id=version_id,
            topic_ids=topic_ids,
            exclude_statuses=exclude_statuses,
            tag_ids=tag_ids,
            workflow_node_entered_id=workflow_node_entered_id,
            termination_reasons=termination_reasons,
            request_options=request_options,
        )
        return _response.data

    def resolve(
        self, *, agent_id: str, reference: str, request_options: typing.Optional[RequestOptions] = None
    ) -> GetConversationResponseModel:
        """
        Resolve a conversation URL (a Slack message URL or a Zendesk ticket URL) to the deterministic conversation ID for the given agent, then confirm the conversation exists.

        Parameters
        ----------
        agent_id : str
            Agent id (agent_…) or speech engine external id (seng_), resolved to the same underlying resource.

        reference : str
            A Slack message URL or a Zendesk ticket URL.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetConversationResponseModel
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.resolve(
            agent_id="agent_3701k3ttaq12ewp8b7qv5rfyszkz",
            reference="https://your-domain.zendesk.com/agent/tickets/12345",
        )
        """
        _response = self._raw_client.resolve(agent_id=agent_id, reference=reference, request_options=request_options)
        return _response.data

    def get(
        self,
        conversation_id: str,
        *,
        format: typing.Optional[ConversationsGetRequestFormat] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetConversationResponseModel:
        """
        Get the details of a particular conversation

        Parameters
        ----------
        conversation_id : str
            The id of the conversation you're taking the action on.

        format : typing.Optional[ConversationsGetRequestFormat]
            Response format. Defaults to 'json'. Set to 'opentelemetry' for an OTLP-compatible trace payload using the same structure as the post-call webhook.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetConversationResponseModel
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.get(
            conversation_id="21m00Tcm4TlvDq8ikWAM",
            format="json",
        )
        """
        _response = self._raw_client.get(conversation_id, format=format, request_options=request_options)
        return _response.data

    def delete(self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
        """
        Delete a particular conversation

        Parameters
        ----------
        conversation_id : str
            The id of the conversation you're taking the action on.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.delete(
            conversation_id="21m00Tcm4TlvDq8ikWAM",
        )
        """
        _response = self._raw_client.delete(conversation_id, request_options=request_options)
        return _response.data

    def get_sip_messages(
        self,
        conversation_id: str,
        *,
        page_size: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetSipLogMessagesResponse:
        """
        Get SIP messages associated with a conversation's phone call

        Parameters
        ----------
        conversation_id : str
            The id of the conversation you're taking the action on.

        page_size : typing.Optional[int]

        cursor : typing.Optional[str]
            Used for fetching next page. Cursor is returned in the response.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetSipLogMessagesResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.get_sip_messages(
            conversation_id="21m00Tcm4TlvDq8ikWAM",
            page_size=1,
            cursor="cursor",
        )
        """
        _response = self._raw_client.get_sip_messages(
            conversation_id, page_size=page_size, cursor=cursor, request_options=request_options
        )
        return _response.data

    @property
    def audio(self):
        if self._audio is None:
            from .audio.client import AudioClient  # noqa: E402

            self._audio = AudioClient(client_wrapper=self._client_wrapper)
        return self._audio

    @property
    def feedback(self):
        if self._feedback is None:
            from .feedback.client import FeedbackClient  # noqa: E402

            self._feedback = FeedbackClient(client_wrapper=self._client_wrapper)
        return self._feedback

    @property
    def messages(self):
        if self._messages is None:
            from .messages.client import MessagesClient  # noqa: E402

            self._messages = MessagesClient(client_wrapper=self._client_wrapper)
        return self._messages

    @property
    def tags(self):
        if self._tags is None:
            from .tags.client import TagsClient  # noqa: E402

            self._tags = TagsClient(client_wrapper=self._client_wrapper)
        return self._tags

    @property
    def files(self):
        if self._files is None:
            from .files.client import FilesClient  # noqa: E402

            self._files = FilesClient(client_wrapper=self._client_wrapper)
        return self._files

    @property
    def topics(self):
        if self._topics is None:
            from .topics.client import TopicsClient  # noqa: E402

            self._topics = TopicsClient(client_wrapper=self._client_wrapper)
        return self._topics

    @property
    def analysis(self):
        if self._analysis is None:
            from .analysis.client import AnalysisClient  # noqa: E402

            self._analysis = AnalysisClient(client_wrapper=self._client_wrapper)
        return self._analysis


class AsyncConversationsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawConversationsClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._audio: typing.Optional[AsyncAudioClient] = None
        self._feedback: typing.Optional[AsyncFeedbackClient] = None
        self._messages: typing.Optional[AsyncMessagesClient] = None
        self._tags: typing.Optional[AsyncTagsClient] = None
        self._files: typing.Optional[AsyncFilesClient] = None
        self._topics: typing.Optional[AsyncTopicsClient] = None
        self._analysis: typing.Optional[AsyncAnalysisClient] = None

    @property
    def with_raw_response(self) -> AsyncRawConversationsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawConversationsClient
        """
        return self._raw_client

    async def get_signed_url(
        self,
        *,
        agent_id: str,
        include_conversation_id: typing.Optional[bool] = None,
        branch_id: typing.Optional[str] = None,
        environment: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ConversationSignedUrlResponseModel:
        """
        Get a signed url to start a conversation with an agent with an agent that requires authorization

        Parameters
        ----------
        agent_id : str
            Agent id (agent_…) or speech engine external id (seng_), resolved to the same underlying resource.

        include_conversation_id : typing.Optional[bool]
            Whether to include a conversation_id with the response. If included, the conversation_signature cannot be used again.

        branch_id : typing.Optional[str]
            The ID of the branch to use

        environment : typing.Optional[str]
            The environment to use for resolving environment variables (e.g. 'production', 'staging'). Defaults to 'production'.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ConversationSignedUrlResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.get_signed_url(
                agent_id="agent_3701k3ttaq12ewp8b7qv5rfyszkz",
                include_conversation_id=True,
                branch_id="branch_id",
                environment="environment",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_signed_url(
            agent_id=agent_id,
            include_conversation_id=include_conversation_id,
            branch_id=branch_id,
            environment=environment,
            request_options=request_options,
        )
        return _response.data

    async def get_webrtc_token(
        self,
        *,
        agent_id: str,
        participant_name: typing.Optional[str] = None,
        branch_id: typing.Optional[str] = None,
        environment: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TokenResponseModel:
        """
        Get a WebRTC session token for real-time communication.

        Parameters
        ----------
        agent_id : str
            Agent id (agent_…) or speech engine external id (seng_), resolved to the same underlying resource.

        participant_name : typing.Optional[str]
            Optional custom participant name. If not provided, user ID will be used

        branch_id : typing.Optional[str]
            The ID of the branch to use

        environment : typing.Optional[str]
            The environment to use for resolving environment variables (e.g. 'production', 'staging'). Defaults to 'production'.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        TokenResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.get_webrtc_token(
                agent_id="agent_3701k3ttaq12ewp8b7qv5rfyszkz",
                participant_name="participant_name",
                branch_id="branch_id",
                environment="environment",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_webrtc_token(
            agent_id=agent_id,
            participant_name=participant_name,
            branch_id=branch_id,
            environment=environment,
            request_options=request_options,
        )
        return _response.data

    async def list(
        self,
        *,
        cursor: typing.Optional[str] = None,
        agent_id: typing.Optional[str] = None,
        visited_agent_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        visited_agent_branch_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        call_successful: typing.Optional[EvaluationSuccessResult] = None,
        call_start_before_unix: typing.Optional[int] = None,
        call_start_after_unix: typing.Optional[int] = None,
        call_duration_min_secs: typing.Optional[int] = None,
        call_duration_max_secs: typing.Optional[int] = None,
        rating_max: typing.Optional[int] = None,
        rating_min: typing.Optional[int] = None,
        has_feedback_comment: typing.Optional[bool] = None,
        user_id: typing.Optional[str] = None,
        evaluation_params: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        data_collection_params: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        data_collection_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        evaluation_criteria_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        tool_names: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        tool_names_successful: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        tool_names_errored: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        main_languages: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        page_size: typing.Optional[int] = None,
        summary_mode: typing.Optional[ConversationsListRequestSummaryMode] = None,
        search: typing.Optional[str] = None,
        conversation_initiation_source: typing.Optional[ConversationInitiationSource] = None,
        text_only: typing.Optional[bool] = None,
        conversation_product_type: typing.Optional[ConversationProduct] = None,
        branch_id: typing.Optional[str] = None,
        version_id: typing.Optional[str] = None,
        topic_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        exclude_statuses: typing.Optional[
            typing.Union[
                ConversationsListRequestExcludeStatusesItem,
                typing.Sequence[ConversationsListRequestExcludeStatusesItem],
            ]
        ] = None,
        tag_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        workflow_node_entered_id: typing.Optional[str] = None,
        termination_reasons: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetConversationsPageResponseModel:
        """
        Get all conversations of agents that user owns. With option to restrict to a specific agent.

        Parameters
        ----------
        cursor : typing.Optional[str]
            Used for fetching next page. Cursor is returned in the response.

        agent_id : typing.Optional[str]
            Agent id (agent_…) or speech engine external id (seng_), resolved to the same underlying resource.

        visited_agent_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations where any of these agents participated. Can not exceed 50 values.

        visited_agent_branch_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations where any of these agent branches participated. Can not exceed 50 values.

        call_successful : typing.Optional[EvaluationSuccessResult]
            The result of the success evaluation

        call_start_before_unix : typing.Optional[int]
            Unix timestamp (in seconds) to filter conversations up to this start date.

        call_start_after_unix : typing.Optional[int]
            Unix timestamp (in seconds) to filter conversations after to this start date.

        call_duration_min_secs : typing.Optional[int]
            Minimum call duration in seconds.

        call_duration_max_secs : typing.Optional[int]
            Maximum call duration in seconds.

        rating_max : typing.Optional[int]
            Maximum overall rating (1-5).

        rating_min : typing.Optional[int]
            Minimum overall rating (1-5).

        has_feedback_comment : typing.Optional[bool]
            Filter conversations with user feedback comments.

        user_id : typing.Optional[str]
            Filter conversations by the user ID who initiated them.

        evaluation_params : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Evaluation filters. Repeat param. Format: criteria_id:result. Example: eval=value_framing:success

        data_collection_params : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Data collection filters. Repeat param. Format: id:op:value where op is one of eq|neq|gt|gte|lt|lte|in|exists|missing. For in, pipe-delimit values.

        data_collection_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Data collection field IDs to include in each conversation summary. Repeat param. When omitted, data_collection_results is not returned.

        evaluation_criteria_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Evaluation criteria IDs to include in each conversation summary. Repeat param. When omitted, evaluation_criteria_results is not returned.

        tool_names : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations by tool names used during the call.

        tool_names_successful : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations by tool names that had successful calls.

        tool_names_errored : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations by tool names that had errored calls.

        main_languages : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations by detected main language (language code).

        page_size : typing.Optional[int]
            How many conversations to return at maximum. Can not exceed 100, defaults to 30.

        summary_mode : typing.Optional[ConversationsListRequestSummaryMode]
            Whether to include transcript summaries in the response.

        search : typing.Optional[str]
            Full-text or fuzzy search over transcript messages

        conversation_initiation_source : typing.Optional[ConversationInitiationSource]

        text_only : typing.Optional[bool]

        conversation_product_type : typing.Optional[ConversationProduct]
            Restrict results to a single conversation product surface.

        branch_id : typing.Optional[str]
            Filter conversations by branch ID.

        version_id : typing.Optional[str]
            Filter conversations by version ID.

        topic_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations by topic IDs assigned during topic discovery.

        exclude_statuses : typing.Optional[typing.Union[ConversationsListRequestExcludeStatusesItem, typing.Sequence[ConversationsListRequestExcludeStatusesItem]]]
            Exclude conversations with the given statuses. Useful for hiding in-progress / processing conversations from list views.

        tag_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations by conversation tag IDs assigned via the conversation-tags endpoints.

        workflow_node_entered_id : typing.Optional[str]
            Filter conversations to only those that entered the given node.

        termination_reasons : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Filter conversations by their stored termination_reason (metadata.termination_reason). Repeat param to match any of several.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetConversationsPageResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.list(
                cursor="cursor",
                agent_id="agent_id",
                visited_agent_ids=["visited_agent_ids"],
                visited_agent_branch_ids=["visited_agent_branch_ids"],
                call_successful="success",
                call_start_before_unix=1,
                call_start_after_unix=1,
                call_duration_min_secs=1,
                call_duration_max_secs=1,
                rating_max=1,
                rating_min=1,
                has_feedback_comment=True,
                user_id="user_id",
                evaluation_params=["evaluation_params"],
                data_collection_params=["data_collection_params"],
                data_collection_ids=["data_collection_ids"],
                evaluation_criteria_ids=["evaluation_criteria_ids"],
                tool_names=["tool_names"],
                tool_names_successful=["tool_names_successful"],
                tool_names_errored=["tool_names_errored"],
                main_languages=["main_languages"],
                page_size=1,
                summary_mode="exclude",
                search="search",
                conversation_initiation_source="unknown",
                text_only=True,
                conversation_product_type="agents",
                branch_id="branch_id",
                version_id="version_id",
                topic_ids=["topic_ids"],
                exclude_statuses=["initiated"],
                tag_ids=["tag_ids"],
                workflow_node_entered_id="workflow_node_entered_id",
                termination_reasons=["termination_reasons"],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list(
            cursor=cursor,
            agent_id=agent_id,
            visited_agent_ids=visited_agent_ids,
            visited_agent_branch_ids=visited_agent_branch_ids,
            call_successful=call_successful,
            call_start_before_unix=call_start_before_unix,
            call_start_after_unix=call_start_after_unix,
            call_duration_min_secs=call_duration_min_secs,
            call_duration_max_secs=call_duration_max_secs,
            rating_max=rating_max,
            rating_min=rating_min,
            has_feedback_comment=has_feedback_comment,
            user_id=user_id,
            evaluation_params=evaluation_params,
            data_collection_params=data_collection_params,
            data_collection_ids=data_collection_ids,
            evaluation_criteria_ids=evaluation_criteria_ids,
            tool_names=tool_names,
            tool_names_successful=tool_names_successful,
            tool_names_errored=tool_names_errored,
            main_languages=main_languages,
            page_size=page_size,
            summary_mode=summary_mode,
            search=search,
            conversation_initiation_source=conversation_initiation_source,
            text_only=text_only,
            conversation_product_type=conversation_product_type,
            branch_id=branch_id,
            version_id=version_id,
            topic_ids=topic_ids,
            exclude_statuses=exclude_statuses,
            tag_ids=tag_ids,
            workflow_node_entered_id=workflow_node_entered_id,
            termination_reasons=termination_reasons,
            request_options=request_options,
        )
        return _response.data

    async def resolve(
        self, *, agent_id: str, reference: str, request_options: typing.Optional[RequestOptions] = None
    ) -> GetConversationResponseModel:
        """
        Resolve a conversation URL (a Slack message URL or a Zendesk ticket URL) to the deterministic conversation ID for the given agent, then confirm the conversation exists.

        Parameters
        ----------
        agent_id : str
            Agent id (agent_…) or speech engine external id (seng_), resolved to the same underlying resource.

        reference : str
            A Slack message URL or a Zendesk ticket URL.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetConversationResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.resolve(
                agent_id="agent_3701k3ttaq12ewp8b7qv5rfyszkz",
                reference="https://your-domain.zendesk.com/agent/tickets/12345",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.resolve(
            agent_id=agent_id, reference=reference, request_options=request_options
        )
        return _response.data

    async def get(
        self,
        conversation_id: str,
        *,
        format: typing.Optional[ConversationsGetRequestFormat] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetConversationResponseModel:
        """
        Get the details of a particular conversation

        Parameters
        ----------
        conversation_id : str
            The id of the conversation you're taking the action on.

        format : typing.Optional[ConversationsGetRequestFormat]
            Response format. Defaults to 'json'. Set to 'opentelemetry' for an OTLP-compatible trace payload using the same structure as the post-call webhook.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetConversationResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.get(
                conversation_id="21m00Tcm4TlvDq8ikWAM",
                format="json",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get(conversation_id, format=format, request_options=request_options)
        return _response.data

    async def delete(
        self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Delete a particular conversation

        Parameters
        ----------
        conversation_id : str
            The id of the conversation you're taking the action on.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.delete(
                conversation_id="21m00Tcm4TlvDq8ikWAM",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete(conversation_id, request_options=request_options)
        return _response.data

    async def get_sip_messages(
        self,
        conversation_id: str,
        *,
        page_size: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetSipLogMessagesResponse:
        """
        Get SIP messages associated with a conversation's phone call

        Parameters
        ----------
        conversation_id : str
            The id of the conversation you're taking the action on.

        page_size : typing.Optional[int]

        cursor : typing.Optional[str]
            Used for fetching next page. Cursor is returned in the response.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetSipLogMessagesResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.get_sip_messages(
                conversation_id="21m00Tcm4TlvDq8ikWAM",
                page_size=1,
                cursor="cursor",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_sip_messages(
            conversation_id, page_size=page_size, cursor=cursor, request_options=request_options
        )
        return _response.data

    @property
    def audio(self):
        if self._audio is None:
            from .audio.client import AsyncAudioClient  # noqa: E402

            self._audio = AsyncAudioClient(client_wrapper=self._client_wrapper)
        return self._audio

    @property
    def feedback(self):
        if self._feedback is None:
            from .feedback.client import AsyncFeedbackClient  # noqa: E402

            self._feedback = AsyncFeedbackClient(client_wrapper=self._client_wrapper)
        return self._feedback

    @property
    def messages(self):
        if self._messages is None:
            from .messages.client import AsyncMessagesClient  # noqa: E402

            self._messages = AsyncMessagesClient(client_wrapper=self._client_wrapper)
        return self._messages

    @property
    def tags(self):
        if self._tags is None:
            from .tags.client import AsyncTagsClient  # noqa: E402

            self._tags = AsyncTagsClient(client_wrapper=self._client_wrapper)
        return self._tags

    @property
    def files(self):
        if self._files is None:
            from .files.client import AsyncFilesClient  # noqa: E402

            self._files = AsyncFilesClient(client_wrapper=self._client_wrapper)
        return self._files

    @property
    def topics(self):
        if self._topics is None:
            from .topics.client import AsyncTopicsClient  # noqa: E402

            self._topics = AsyncTopicsClient(client_wrapper=self._client_wrapper)
        return self._topics

    @property
    def analysis(self):
        if self._analysis is None:
            from .analysis.client import AsyncAnalysisClient  # noqa: E402

            self._analysis = AsyncAnalysisClient(client_wrapper=self._client_wrapper)
        return self._analysis
