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

import typing

import pydantic
from ...core.pydantic_utilities import IS_PYDANTIC_V2
from .tool_call_message import ToolCallMessage
from .webhook_event_base import WebhookEventBase


class WebhookEventToolCall(WebhookEventBase):
    caller_number: typing.Optional[str] = pydantic.Field(default=None)
    """
    Phone number of the caller in E.164 format (e.g., `+12223333333`). This field is included only if the Chat was created via the [Twilio phone calling](/docs/empathic-voice-interface-evi/phone-calling) integration.
    """

    custom_session_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    User-defined session ID. Relevant only when employing a [custom language model](/docs/empathic-voice-interface-evi/custom-language-model) in the EVI Config.
    """

    event_name: typing.Optional[typing.Literal["tool_call"]] = pydantic.Field(default=None)
    """
    Always `tool_call`.
    """

    timestamp: int = pydantic.Field()
    """
    Unix timestamp (in milliseconds) indicating when the tool call was triggered.
    """

    tool_call_message: ToolCallMessage = pydantic.Field()
    """
    The tool call.
    """

    twilio_metadata: typing.Optional[typing.Dict[str, typing.Optional[str]]] = pydantic.Field(default=None)
    """
    Twilio metadata associated with the chat. This field is included only if the Chat was created via the [Twilio phone calling](/docs/empathic-voice-interface-evi/phone-calling) integration. Fields may include `call_sid`, `account_sid`, `from_number`, `to_number`, `caller_name`, `caller_number`, `from_city`, `from_state`, `from_zip`, `from_country`, `to_city`, `to_state`, `to_zip`, and `to_country`.If a specific metadata is not available, this field will be set to an empty string.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
