Skip to contentSkip to navigationSkip to topbar
On this page

Voice in Twilio Flex


Flex offers basic functionality for inbound and outbound calling capabilities by default. You can augment existing calls using the Programmable Voice API. Programmable Voice can also be used, alongside other tools like Studio, to set up custom call flows.

Additionally, the Flex UI offers you the ability to customize existing behaviors for inbound and outbound calls using the Actions Framework and Notifications Framework.


Track Voice Usage

track-voice-usage page anchor

You can pull calls in your Flex account by using the Usage Records API and passing pstnconnectivity as the Category parameter. This will show your Programmable Voice usage over the PSTN (aka, the actual telephone network.)

Get PSTN UsageLink to code sample: Get PSTN Usage
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function listUsageRecord() {
11
const records = await client.usage.records.list({
12
category: "pstnconnectivity",
13
limit: 20,
14
});
15
16
records.forEach((r) => console.log(r.accountSid));
17
}
18
19
listUsageRecord();

Output

1
{
2
"end": 0,
3
"first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records?Page=0&PageSize=1",
4
"last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records?Page=68&PageSize=1",
5
"next_page_uri": null,
6
"num_pages": 69,
7
"page": 0,
8
"page_size": 1,
9
"previous_page_uri": null,
10
"start": 0,
11
"total": 69,
12
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records",
13
"usage_records": [
14
{
15
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
16
"api_version": "2010-04-01",
17
"as_of": "2019-06-24T22:32:49+00:00",
18
"category": "totalprice",
19
"count": null,
20
"count_unit": "",
21
"description": "Total Price",
22
"end_date": "2015-09-04",
23
"price": "2192.84855",
24
"price_unit": "usd",
25
"start_date": "2011-08-23",
26
"subresource_uris": {
27
"all_time": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime.json?Category=totalprice",
28
"daily": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily.json?Category=totalprice",
29
"last_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth.json?Category=totalprice",
30
"monthly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly.json?Category=totalprice",
31
"this_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth.json?Category=totalprice",
32
"today": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today.json?Category=totalprice",
33
"yearly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly.json?Category=totalprice",
34
"yesterday": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday.json?Category=totalprice"
35
},
36
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records?Category=totalprice&StartDate=2011-08-23&EndDate=2015-09-04",
37
"usage": "2192.84855",
38
"usage_unit": "usd"
39
}
40
]
41
}

Receiving a call is one of the basic interactions with the Flex UI. Other workflows, like making an outbound call or transferring a call, are more complex. The following end user guides explain how these interactions work in the Flex UI in more detail.


Need some help?

Terms of service

Copyright © 2024 Twilio Inc.