Evo Voice

<back to all web services

NewFlow

Create a new flow

Requires Authentication
Requires any of the roles:SystemAdministrator, Manager, Customer
The following routes are available for this service:
POST/flows
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 FlowRoles(str, Enum):
    UI = 'UI'
    REFERENCE = 'Reference'
    PHONE_NUMBER_ROUTING = 'PhoneNumberRouting'
    USER_DIAL_OUT = 'UserDialOut'
    FAX_NUMBER_ROUTING = 'FaxNumberRouting'


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


class FlowNodeCategories(str, Enum):
    GENERAL = 'General'
    VOICE = 'Voice'
    LOGIC = 'Logic'
    DATE_AND_TIME = 'DateAndTime'
    AUDIO = 'Audio'
    MESSAGING = 'Messaging'
    ASSISTANT = 'Assistant'
    FLOWS = 'Flows'
    FAX = 'Fax'
    NETWORK = 'Network'
    COOKIES = 'Cookies'
    CALL_CENTER = 'CallCenter'
    INTELLIGENCE = 'Intelligence'


class ValueTypes(str, Enum):
    NOT_SPECIFIED = 'NotSpecified'
    STRING = 'String'
    BOOLEAN = 'Boolean'
    NUMBER = 'Number'
    LIST = 'List'
    STRUCT = 'Struct'
    TRANSITION = 'Transition'
    CUSTOM = 'Custom'
    DATE = 'Date'
    AUDIO_FILE = 'AudioFile'
    TIME_ZONE_ID = 'TimeZoneId'
    PHONE_NUMBER = 'PhoneNumber'
    USER = 'User'
    ENDPOINT = 'Endpoint'
    TIME = 'Time'
    FILE = 'File'
    FAX_NUMBER = 'FaxNumber'
    EMAIL_ACCOUNT = 'EmailAccount'
    CUSTOMER = 'Customer'
    FLOW = 'Flow'
    TEAM = 'Team'
    FLOW_REFERENCE = 'FlowReference'
    INTEGRATION = 'Integration'
    ASSISTANT = 'Assistant'


class UIHints(str, Enum):
    NONE = 'None'
    LARGE_TEXT = 'LargeText'
    INLINE_FORM = 'InlineForm'
    PASSWORD = 'Password'
    INLINE_STRUCT = 'InlineStruct'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Struct(Dict[str,Value]):
    pass


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Value:
    bool_value: Optional[bool] = None
    string_value: Optional[str] = None
    number_value: Optional[float] = None
    list_value: Optional[List[Struct]] = None
    struct_value: Optional[Struct] = None


class DataFieldUniqueness(str, Enum):
    NOT_UNIQUE = 'NotUnique'
    UNIQUE = 'Unique'
    UNIQUE_TO_CUSTOMER = 'UniqueToCustomer'


class UserDataFieldModes(str, Enum):
    HIDDEN = 'Hidden'
    READ_ONLY = 'ReadOnly'
    READ_WRITE = 'ReadWrite'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class DataField:
    id: Optional[str] = None
    name: Optional[str] = None
    type: Optional[ValueTypes] = None
    ui_hint: Optional[UIHints] = None
    ui_tab: Optional[str] = None
    is_async: bool = False
    disable_binding: bool = False
    struct_type: Optional[DataType] = None
    list_type: Optional[DataType] = None
    description: Optional[str] = None
    possible_values: Optional[List[str]] = None
    is_output: bool = False
    custom_field_values_url: Optional[str] = None
    default_value: Optional[Value] = None
    transition_name_format: Optional[str] = None
    uniqueness: Optional[DataFieldUniqueness] = None
    voice_only: bool = False
    conditional_visibility_field: Optional[str] = None
    conditional_visibility_value: Optional[str] = None
    no_eval_template: bool = False
    user_mode: Optional[UserDataFieldModes] = None
    any_value_type: bool = False


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class DataType:
    type_name: Optional[str] = None
    fields: Optional[List[DataField]] = None


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


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class FlowNodeSpec:
    # @ApiMember(Description="The name of this node")
    name: Optional[str] = None
    """
    The name of this node
    """


    # @ApiMember(Description="A description of this node")
    description: Optional[str] = None
    """
    A description of this node
    """


    # @ApiMember(Description="Icon class for this node (FontAwesome)")
    icon_class: Optional[str] = None
    """
    Icon class for this node (FontAwesome)
    """


    # @ApiMember(Description="The type name for this node")
    type_name: Optional[str] = None
    """
    The type name for this node
    """


    # @ApiMember(Description="The category this node should be grouped under")
    category: Optional[FlowNodeCategories] = None
    """
    The category this node should be grouped under
    """


    # @ApiMember(Description="The URL where this node is located")
    url: Optional[str] = None
    """
    The URL where this node is located
    """


    # @ApiMember(Description="The data type for this node")
    data_type: Optional[DataType] = None
    """
    The data type for this node
    """


    # @ApiMember(Description="URL for documentation for this node")
    documentation_url: Optional[str] = None
    """
    URL for documentation for this node
    """


    # @ApiMember(Description="The channels that this node is restricted to")
    restrict_to_channels: Optional[List[FlowChannels]] = None
    """
    The channels that this node is restricted to
    """


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class FlowNodeUI:
    # @ApiMember(Description="The X position of the node")
    x: float = 0.0
    """
    The X position of the node
    """


    # @ApiMember(Description="The Y position of the node")
    y: float = 0.0
    """
    The Y position of the node
    """


    # @ApiMember(Description="Notes for this node")
    notes: Optional[str] = None
    """
    Notes for this node
    """


class ValueSources(str, Enum):
    VALUE = 'Value'
    FLOW = 'Flow'
    SYSTEM = 'System'
    CUSTOMER = 'Customer'
    SESSION = 'Session'
    ENDPOINT = 'Endpoint'
    EXPRESSION = 'Expression'
    USER = 'User'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class NodeParameter:
    id: Optional[str] = None
    type: Optional[ValueTypes] = None
    source: Optional[ValueSources] = None
    is_async: bool = False
    reference_id: Optional[str] = None
    value: Optional[Value] = None
    no_eval_template: bool = False
    list_parameters: Optional[List[NodeParameterMap]] = None
    struct_parameters: Optional[NodeParameterMap] = None
    is_output: bool = False
    expression: Optional[str] = None
    list_type: Optional[DataType] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class NodeParameterMap(Dict[str,NodeParameter]):
    pass


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class FlowNode:
    # @ApiMember(Description="The ID of this node. Must be unique within the flow but can be anything")
    id: Optional[str] = None
    """
    The ID of this node. Must be unique within the flow but can be anything
    """


    # @ApiMember(Description="Is this the starting node for the flow. Only one node can have this set")
    is_start_node: bool = False
    """
    Is this the starting node for the flow. Only one node can have this set
    """


    # @ApiMember(Description="The name of the node, descriptive to be used as a reminder in the GUI")
    name: Optional[str] = None
    """
    The name of the node, descriptive to be used as a reminder in the GUI
    """


    # @ApiMember(Description="The specification for the node")
    spec: Optional[FlowNodeSpec] = None
    """
    The specification for the node
    """


    # @ApiMember(Description="The UI data for the node")
    ui: Optional[FlowNodeUI] = None
    """
    The UI data for the node
    """


    # @ApiMember(Description="The data for this node. These will be POST'd to the endpoint when it is called.")
    parameters: Optional[NodeParameterMap] = None
    """
    The data for this node. These will be POST'd to the endpoint when it is called.
    """


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class FlowParameter(DataField):
    is_public: bool = False
    is_knob: bool = False


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class FlowExit:
    # @ApiMember(Description="The unique ID for this exit")
    id: Optional[str] = None
    """
    The unique ID for this exit
    """


    # @ApiMember(Description="The name of this exit")
    name: Optional[str] = None
    """
    The name of this exit
    """


    # @ApiMember(Description="The UI for the exit")
    ui: Optional[FlowNodeUI] = None
    """
    The UI for the exit
    """


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class FlowUI:
    selected_node: Optional[str] = None
    canvas_x: float = 0.0
    canvas_y: float = 0.0
    canvas_zoom: float = 0.0


class TagColors(str, Enum):
    MAGENTA = 'Magenta'
    RED = 'Red'
    VOLCANO = 'Volcano'
    ORANGE = 'Orange'
    GOLD = 'Gold'
    LIME = 'Lime'
    GREEN = 'Green'
    CYAN = 'Cyan'
    BLUE = 'Blue'
    GEEK_BLUE = 'GeekBlue'
    PURPLE = 'Purple'


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


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class FlowInfo(EntityInfo):
    # @ApiMember(Description="The name of this flow")
    name: Optional[str] = None
    """
    The name of this flow
    """


    # @ApiMember(Description="The roles that this flow has")
    roles: Optional[List[FlowRoles]] = None
    """
    The roles that this flow has
    """


    # @ApiMember(Description="What this flow does")
    description: Optional[str] = None
    """
    What this flow does
    """


    # @ApiMember(Description="Any notes for this flow")
    notes: Optional[str] = None
    """
    Any notes for this flow
    """


    # @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 flow")
    account_name: Optional[str] = None
    """
    The name of the account associated with the flow
    """


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


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


    # @ApiMember(Description="The breadcrumb to the flow for this endpoint")
    customer_breadcrumb: Optional[List[CustomerBreadcrumb]] = None
    """
    The breadcrumb to the flow for this endpoint
    """


    # @ApiMember(Description="The nodes in this flow")
    nodes: Optional[List[FlowNode]] = None
    """
    The nodes in this flow
    """


    # @ApiMember(Description="The flow's parameters")
    parameters: Optional[List[FlowParameter]] = None
    """
    The flow's parameters
    """


    # @ApiMember(Description="The flow's exits")
    exits: Optional[List[FlowExit]] = None
    """
    The flow's exits
    """


    # @ApiMember(Description="The UI data for the flow")
    ui: Optional[FlowUI] = None
    """
    The UI data for the flow
    """


    # @ApiMember(Description="The list of tags for this flow")
    tags: Optional[List[Tag]] = None
    """
    The list of tags for this flow
    """


    # @ApiMember(Description="The number of nodes in this flow")
    node_count: int = 0
    """
    The number of nodes in this flow
    """


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

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


    # @ApiMember(Description="The ID of the customer to associate with the flow")
    customer_id: Optional[str] = None
    """
    The ID of the customer to associate with the flow
    """


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


    # @ApiMember(Description="The roles that this flow has")
    roles: Optional[List[FlowRoles]] = None
    """
    The roles that this flow has
    """


    # @ApiMember(Description="The list of nodes for this flow")
    nodes: Optional[List[FlowNode]] = None
    """
    The list of nodes for this flow
    """

Python NewFlow DTOs

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

HTTP + JSV

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

POST /flows HTTP/1.1 
Host: team.evovoice.io 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	accountId: String,
	customerId: String,
	name: String,
	roles: 
	[
		UI
	],
	nodes: 
	[
		{
			id: String,
			isStartNode: False,
			name: String,
			spec: 
			{
				name: String,
				description: String,
				iconClass: String,
				typeName: String,
				category: General,
				url: String,
				documentationUrl: String,
				restrictToChannels: 
				[
					Voice
				]
			},
			ui: 
			{
				x: 0,
				y: 0,
				notes: String
			},
			parameters: {}
		}
	]
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	name: String,
	roles: 
	[
		UI
	],
	description: String,
	notes: String,
	accountId: String,
	accountName: String,
	customerId: String,
	customerName: String,
	customerBreadcrumb: 
	[
		{
			id: String,
			name: String
		}
	],
	nodes: 
	[
		{
			id: String,
			isStartNode: False,
			name: String,
			spec: 
			{
				name: String,
				description: String,
				iconClass: String,
				typeName: String,
				category: General,
				url: String,
				documentationUrl: String,
				restrictToChannels: 
				[
					Voice
				]
			},
			ui: 
			{
				x: 0,
				y: 0,
				notes: String
			},
			parameters: {}
		}
	],
	parameters: 
	[
		{
			isPublic: False,
			isKnob: False,
			id: String,
			name: String,
			type: NotSpecified,
			uiHint: None,
			uiTab: String,
			isAsync: False,
			disableBinding: False,
			description: String,
			possibleValues: 
			[
				String
			],
			isOutput: False,
			customFieldValuesUrl: String,
			defaultValue: 
			{
				boolValue: False,
				stringValue: String,
				numberValue: 0,
				listValue: 
				[
					null
				]
			},
			transitionNameFormat: String,
			uniqueness: NotUnique,
			voiceOnly: False,
			conditionalVisibilityField: String,
			conditionalVisibilityValue: String,
			noEvalTemplate: False,
			userMode: Hidden,
			anyValueType: False
		}
	],
	exits: 
	[
		{
			id: String,
			name: String,
			ui: 
			{
				x: 0,
				y: 0,
				notes: String
			}
		}
	],
	ui: 
	{
		selectedNode: String,
		canvasX: 0,
		canvasY: 0,
		canvasZoom: 0
	},
	tags: 
	[
		{
			id: String,
			name: String,
			color: Magenta
		}
	],
	nodeCount: 0,
	id: String,
	dateCreated: String,
	dateLastModified: String,
	createdBy: String,
	lastModifiedBy: String
}