Call Flows

Table of Contents

Overview

So... this one is complicated. Well, kind of. Create and update are complicated. All the flow data itself is JSON (stringified). And there are rules to this JSON...

[
    {
        "command": "route",
        "options": {
            "duration": "5",
            "destination": {
                "type": "call_forward",
                "value": "5555555555"
            }
        }
    }
]

This is about the simplest call flow you can have. All inbound calls to it will do a call forward to the number 5555555555 and ring for 5 seconds.

First, note that this is all inside an array. The reason for this is because every call flow will be an array with up to 2 elements. The first element is the primary route. The second, optional element, is the failover route.

Next, the command. There are 4 possible options for the command: route, hunt_group, ring_group and load_balance. These reglect the different Flow Types in the user portal. Each one has options associated with it.

duration: Depending on the command, duration could mean one of two things. For route, ring_group and load_balance it will determine how long, in seconds, to ring a destination before failing. For hunt_group the duration specifies how long will ring each endpoint before moving onto the next.

destination: This is used for route only. Everything else uses "destinations" (note that it is plural). But, within "destinations" is simply an array with multiple of the destination object.

//call_forward
{
    "type": "call_forward",
    "value": "5555555555"
}

//ip_endpoint
{
    "type": "ip_endpoint",
    "value": "456"
}

//sip_account
{
    "type": "sip_account",
    "value": "654"
}

Every destination has a type and value. Types can be call_forward, ip_endpoint or sip_account. For call_forward, the value is the number you wish to forward to. For ip_endpoint, value is the ID (retrieved from /ipendpoints/list) of the endpoint you wish assigned. For sip_account, value is the ID (retrieved from /sipaccounts/list) of the SIP account you wish assigned.

destinations (used with hunt_group, ring_group, load_balance commands):

[
    {
        "command": "hunt_group",
        "options": {
            "duration": "5",
            "destinations": [
                {
                    "type": "call_forward",
                    "value": "5555555555"
                },
                {
                    "type": "call_forward",
                    "value": "5555555556"
                }
            ]
        }
    }
]

See? Just an array of destinations. All the same types and values apply, you can just shove up to 5 of them in there.

Primary and Failover routes:

[
    {
        "command": "route",
        "options": {
            "duration": "5",
            "destination": {
                "type": "call_forward",
                "value": "5555555555"
            }
        }
    },
    {
        "command": "route",
        "options": {
            "duration": "5",
            "destination": {
                "type": "call_forward",
                "value": "5555555556"
            }
        }
    }
]

In the call flow array, the first element is the primary route and the second element is the failover route. There can only be up to 2 elements in this array (primary and failover). Sorry, but that's just how it is for now.

Limitations:

We hope to eliminate these limitations and even add some bigger, better features in the future. But, for now, this is what we can do. Now... on to the actual API calls. Finally.

Controller: /flows
Full Url: https://apiv1.teleapi.net/flows/

Functions

/flows/create

Full Url: https://apiv1.teleapi.net/flows/create

Arguments:

Info: This will create a new call flow with the given name and flow data. Note that names are unique to your user account. See above for proper format on flow_data. Returns the ID of the newly created call flow in the data section of the response.

/flows/list

Full Url: https://apiv1.teleapi.net/flows/list

Arguments:

Info: This will return a list of all of your call flows.

/flows/get

Full Url: https://apiv1.teleapi.net/flows/get

Arguments:

Info: Returns all pertinent data for a specific call flow. As a bonus, will return all the attached numbers as well.

/flows/update

Full Url: https://apiv1.teleapi.net/flows/update

Arguments:

Info: Update information about a call flow. Send flow_name to update the name of the flow, flow_data to update the call flow itself. See above for information on properly formatting flow_data.

/flows/remove

Full Url: https://apiv1.teleapi.net/flows/remove

Arguments:

Info: Permanently remove a call flow.

/flows/default/set

Full Url: https://apiv1.teleapi.net/flows/default/set

Arguments:

Info: Set the default call flow for new numbers

/flows/did/assign

Full Url: https://apiv1.teleapi.net/flows/did/assign

Arguments:

Info: Assign a call flow to a phone number. Pass flow_id of "none" to remove from all call flows. Exact same API call as /user/dids/flow