Evo Voice

<back to all web services

NewSession

Create a new session

Requires Authentication
Required role:User
The following routes are available for this service:
POST/sessions
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class EntityInfo:
    # @ApiMember(Description="The ID of the object")
    id: Optional[str] = None
    """
    The ID of the object
    """


    # @ApiMember(Description="The date the object was created")
    date_created: Optional[str] = None
    """
    The date the object was created
    """


    # @ApiMember(Description="The date the object was last modified")
    date_last_modified: Optional[str] = None
    """
    The date the object was last modified
    """


    # @ApiMember(Description="The user that created this object")
    created_by: Optional[str] = None
    """
    The user that created this object
    """


    # @ApiMember(Description="The user that last modified this object")
    last_modified_by: Optional[str] = None
    """
    The user that last modified this object
    """


class SessionDialState(str, Enum):
    NONE = 'None'
    ACTIVE = 'Active'


class SessionCallState(str, Enum):
    DISCONNECTED = 'Disconnected'
    RINGING = 'Ringing'
    CONNECTED = 'Connected'
    HOLD = 'Hold'
    PASSIVE = 'Passive'


class SessionQueueStates(str, Enum):
    NONE = 'None'
    QUEUED = 'Queued'
    RINGING = 'Ringing'
    CONNECTED = 'Connected'
    HOLD = 'Hold'
    DISCONNECTED = 'Disconnected'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomerBreadcrumb:
    id: Optional[str] = None
    name: Optional[str] = None


class FlowChannels(str, Enum):
    VOICE = 'Voice'
    CHAT = 'Chat'
    FAX = 'Fax'


class SessionHoldReasons(str, Enum):
    NONE = 'None'
    TRANSFERRING = 'Transferring'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class SessionLogInfo:
    date: Optional[str] = None
    message: Optional[str] = None


class SessionMemberCallState(str, Enum):
    NONE = 'None'
    RINGING = 'Ringing'
    CONNECTED = 'Connected'
    HOLD = 'Hold'


class SessionMemberRoles(str, Enum):
    NONE = 'None'
    CALLER = 'Caller'
    AGENT = 'Agent'
    TRANSFER = 'Transfer'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class SessionMemberInfo:
    identity: Optional[str] = None
    endpoint_id: Optional[str] = None
    display_name: Optional[str] = None
    is_original_member: Optional[bool] = None
    avatar_url: Optional[str] = None
    application_data: Optional[Dict[str, str]] = None
    call_state: Optional[SessionMemberCallState] = None
    role: Optional[SessionMemberRoles] = None
    call_sid: Optional[str] = None
    muted: Optional[bool] = None


class SessionDirections(str, Enum):
    INCOMING = 'Incoming'
    OUTGOING = 'Outgoing'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class SessionInfo(EntityInfo):
    # @ApiMember(Description="The state of the session")
    dial_state: Optional[SessionDialState] = None
    """
    The state of the session
    """


    # @ApiMember(Description="The call state of the session")
    call_state: Optional[SessionCallState] = None
    """
    The call state of the session
    """


    # @ApiMember(Description="The queue state of the session")
    queue_state: Optional[SessionQueueStates] = None
    """
    The queue state of the session
    """


    # @ApiMember(Description="The ID of the account associated with the flow")
    account_id: Optional[str] = None
    """
    The ID of the account associated with the flow
    """


    # @ApiMember(Description="The name of the account associated with the session")
    account_name: Optional[str] = None
    """
    The name of the account associated with the session
    """


    # @ApiMember(Description="The ID of the customer this session is associated with")
    customer_id: Optional[str] = None
    """
    The ID of the customer this session is associated with
    """


    # @ApiMember(Description="The customer breadcrumb this session is associated with")
    customer_breadcrumb: Optional[List[CustomerBreadcrumb]] = None
    """
    The customer breadcrumb this session is associated with
    """


    # @ApiMember(Description="The name of the customer this session is associated with")
    customer_name: Optional[str] = None
    """
    The name of the customer this session is associated with
    """


    # @ApiMember(Description="The ID of the endpoint associated with this session")
    endpoint_id: Optional[str] = None
    """
    The ID of the endpoint associated with this session
    """


    # @ApiMember(Description="The name of the endpoint associated with this session")
    endpoint_name: Optional[str] = None
    """
    The name of the endpoint associated with this session
    """


    # @ApiMember(Description="The date the call completed")
    date_completed: Optional[str] = None
    """
    The date the call completed
    """


    # @ApiMember(Description="The destination of the session (e.g. what was entered into the Dial box)")
    destination: Optional[str] = None
    """
    The destination of the session (e.g. what was entered into the Dial box)
    """


    # @ApiMember(Description="The to address if any")
    to_address: Optional[str] = None
    """
    The to address if any
    """


    # @ApiMember(Description="The from address if any")
    from_address: Optional[str] = None
    """
    The from address if any
    """


    # @ApiMember(Description="The from name if any")
    from_name: Optional[str] = None
    """
    The from name if any
    """


    # @ApiMember(Description="Answered by name (if any)")
    answered_by_name: Optional[str] = None
    """
    Answered by name (if any)
    """


    # @ApiMember(Description="The ID of the queue member assigned to this call")
    queue_member_id: Optional[str] = None
    """
    The ID of the queue member assigned to this call
    """


    # @ApiMember(Description="The flow channel")
    channel: Optional[FlowChannels] = None
    """
    The flow channel
    """


    # @ApiMember(Description="Has the session ended")
    ended: Optional[bool] = None
    """
    Has the session ended
    """


    # @ApiMember(Description="The outcome of the call")
    outcome: Optional[str] = None
    """
    The outcome of the call
    """


    # @ApiMember(Description="The twilio Call SID of this session")
    call_sid: Optional[str] = None
    """
    The twilio Call SID of this session
    """


    # @ApiMember(Description="Any console data for this session")
    console_data: Optional[str] = None
    """
    Any console data for this session
    """


    # @ApiMember(Description="The name of the hold queue for this call")
    hold_queue_name: Optional[str] = None
    """
    The name of the hold queue for this call
    """


    # @ApiMember(Description="The user ID who put this call on hold")
    held_by_user_id: Optional[str] = None
    """
    The user ID who put this call on hold
    """


    # @ApiMember(Description="The reason for the hold")
    hold_reason: Optional[SessionHoldReasons] = None
    """
    The reason for the hold
    """


    # @ApiMember(Description="The SID of the conference if in a conference call")
    conference_sid: Optional[str] = None
    """
    The SID of the conference if in a conference call
    """


    # @ApiMember(Description="The display name for this session")
    display_name: Optional[str] = None
    """
    The display name for this session
    """


    # @ApiMember(Description="The log entries for this session")
    log: Optional[List[SessionLogInfo]] = None
    """
    The log entries for this session
    """


    # @ApiMember(Description="The members of this session")
    members: Optional[List[SessionMemberInfo]] = None
    """
    The members of this session
    """


    # @ApiMember(Description="The callback number (typically used for SIP to User calls)")
    callback_number: Optional[str] = None
    """
    The callback number (typically used for SIP to User calls)
    """


    # @ApiMember(Description="The ID of the endpoint that answered")
    answered_by_id: Optional[str] = None
    """
    The ID of the endpoint that answered
    """


    # @ApiMember(Description="Is this session incoming or outgoing?")
    direction: Optional[SessionDirections] = None
    """
    Is this session incoming or outgoing?
    """


    # @ApiMember(Description="The phone number that this session is coming from (used with SMS chats)")
    from_phone_number: Optional[str] = None
    """
    The phone number that this session is coming from (used with SMS chats)
    """


    # @ApiMember(Description="The Call SID of the most recently added conference participant")
    most_recent_participant_call_sid: Optional[str] = None
    """
    The Call SID of the most recently added conference participant
    """


    # @ApiMember(Description="Was this session missed?")
    was_missed: Optional[bool] = None
    """
    Was this session missed?
    """


    # @ApiMember(Description="The ring queue that the call is currently in")
    ring_queue_id: Optional[str] = None
    """
    The ring queue that the call is currently in
    """


# @Api(Description="Create a new session")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class NewSession(IPost):
    """
    Create a new session
    """

    # @ApiMember(Description="A display name for this session")
    display_name: Optional[str] = None
    """
    A display name for this session
    """


    # @ApiMember(Description="The type of session")
    channel: Optional[FlowChannels] = None
    """
    The type of session
    """


    # @ApiMember(Description="The session direction (defaults to Outgoing)")
    direction: Optional[SessionDirections] = None
    """
    The session direction (defaults to Outgoing)
    """


    # @ApiMember(Description="The current session call state (defaults to Connected)")
    call_state: Optional[SessionCallState] = None
    """
    The current session call state (defaults to Connected)
    """


    # @ApiMember(Description="The From address for the session (defaults to user's email)")
    from_address: Optional[str] = None
    """
    The From address for the session (defaults to user's email)
    """


    # @ApiMember(Description="The From name for the session")
    from_name: Optional[str] = None
    """
    The From name for the session
    """


    # @ApiMember(Description="The To address for the session")
    to_address: Optional[str] = None
    """
    The To address for the session
    """


    # @ApiMember(Description="Parent session (e.g. for billing purposes)")
    parent_session_id: Optional[str] = None
    """
    Parent session (e.g. for billing purposes)
    """


    # @ApiMember(Description="Specify a customer to associate with this session")
    customer_id: Optional[str] = None
    """
    Specify a customer to associate with this session
    """


    # @ApiMember(Description="Start a chat session with a specified user/team (e.g. user:userid or team:teamid)")
    with_address: Optional[str] = None
    """
    Start a chat session with a specified user/team (e.g. user:userid or team:teamid)
    """


    # @ApiMember(Description="Use the specified caller ID (if dialing out)")
    from_phone_number: Optional[str] = None
    """
    Use the specified caller ID (if dialing out)
    """


    # @ApiMember(Description="The dialed destination value")
    destination: Optional[str] = None
    """
    The dialed destination value
    """


    # @ApiMember(Description="User email addresses to add as members")
    member_email_addresses: Optional[List[str]] = None
    """
    User email addresses to add as members
    """


    # @ApiMember(Description="Start the session's flow?")
    start_session: Optional[bool] = None
    """
    Start the session's flow?
    """

Python NewSession DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml

HTTP + XML

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /sessions HTTP/1.1 
Host: evovoice.io 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<NewSession xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Voice.Api.Sessions">
  <CallState>Disconnected</CallState>
  <Channel>Voice</Channel>
  <CustomerId>String</CustomerId>
  <Destination>String</Destination>
  <Direction>Incoming</Direction>
  <DisplayName>String</DisplayName>
  <FromAddress>String</FromAddress>
  <FromName>String</FromName>
  <FromPhoneNumber>String</FromPhoneNumber>
  <MemberEmailAddresses xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:string>String</d2p1:string>
  </MemberEmailAddresses>
  <ParentSessionId>String</ParentSessionId>
  <StartSession>false</StartSession>
  <ToAddress>String</ToAddress>
  <WithAddress>String</WithAddress>
</NewSession>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<SessionInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Voice.Api.Sessions">
  <CreatedBy xmlns="http://schemas.datacontract.org/2004/07/Voice.Api">String</CreatedBy>
  <DateCreated xmlns="http://schemas.datacontract.org/2004/07/Voice.Api">String</DateCreated>
  <DateLastModified xmlns="http://schemas.datacontract.org/2004/07/Voice.Api">String</DateLastModified>
  <Id xmlns="http://schemas.datacontract.org/2004/07/Voice.Api">String</Id>
  <LastModifiedBy xmlns="http://schemas.datacontract.org/2004/07/Voice.Api">String</LastModifiedBy>
  <AccountId>String</AccountId>
  <AccountName>String</AccountName>
  <AnsweredById>String</AnsweredById>
  <AnsweredByName>String</AnsweredByName>
  <CallSid>String</CallSid>
  <CallState>Disconnected</CallState>
  <CallbackNumber>String</CallbackNumber>
  <Channel>Voice</Channel>
  <ConferenceSid>String</ConferenceSid>
  <ConsoleData>String</ConsoleData>
  <CustomerBreadcrumb xmlns:d2p1="http://schemas.datacontract.org/2004/07/Voice.Api.Customers">
    <d2p1:CustomerBreadcrumb>
      <d2p1:Id>String</d2p1:Id>
      <d2p1:Name>String</d2p1:Name>
    </d2p1:CustomerBreadcrumb>
  </CustomerBreadcrumb>
  <CustomerId>String</CustomerId>
  <CustomerName>String</CustomerName>
  <DateCompleted>String</DateCompleted>
  <Destination>String</Destination>
  <DialState>None</DialState>
  <Direction>Incoming</Direction>
  <DisplayName>String</DisplayName>
  <Ended>false</Ended>
  <EndpointId>String</EndpointId>
  <EndpointName>String</EndpointName>
  <FromAddress>String</FromAddress>
  <FromName>String</FromName>
  <FromPhoneNumber>String</FromPhoneNumber>
  <HeldByUserId>String</HeldByUserId>
  <HoldQueueName>String</HoldQueueName>
  <HoldReason>None</HoldReason>
  <Log>
    <SessionLogInfo>
      <Date>String</Date>
      <Message>String</Message>
    </SessionLogInfo>
  </Log>
  <Members>
    <SessionMemberInfo>
      <ApplicationData xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d4p1:KeyValueOfstringstring>
          <d4p1:Key>String</d4p1:Key>
          <d4p1:Value>String</d4p1:Value>
        </d4p1:KeyValueOfstringstring>
      </ApplicationData>
      <AvatarUrl>String</AvatarUrl>
      <CallSid>String</CallSid>
      <CallState>None</CallState>
      <DisplayName>String</DisplayName>
      <EndpointId>String</EndpointId>
      <Identity>String</Identity>
      <IsOriginalMember>false</IsOriginalMember>
      <Muted>false</Muted>
      <Role>None</Role>
    </SessionMemberInfo>
  </Members>
  <MostRecentParticipantCallSid>String</MostRecentParticipantCallSid>
  <Outcome>String</Outcome>
  <QueueMemberId>String</QueueMemberId>
  <QueueState>None</QueueState>
  <RingQueueId>String</RingQueueId>
  <ToAddress>String</ToAddress>
  <WasMissed>false</WasMissed>
</SessionInfo>