Twilio Read

In this article

Overview

Use this Snap to retrieve data resources from Twilio's REST APIs.

Prerequisites

  • Valid Twilio Account SID.
  • Auth Token corresponding to the Account SID.

Support for Ultra Pipelines

Works in Ultra Pipelines

Limitations and Known Issues

None.

Snap Input and Output

Input/OutputType of ViewNumber of ViewsExamples of Upstream and Downstream SnapsDescription
Input 

Document


  • Min: 0
  • Max: 1
  • Mapper Snap
  • Copy Snap
  • JSON Parser
  • CSV Parser
  • JSON Generator
A document containing details of the entity or data object to read a Twilio entity.
Output

Document


  • Min: 1
  • Max: 1
  • Mapper Snap
  • Copy Snap
  • Router Snap
  • JSON Formatter

A document containing the data retrieved as a Twilio entity.

Snap Settings

Parameter NameData TypeDescriptionDefault ValueExample 
LabelString

Specify a name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline.

Twilio ReadTwilio Read All Entities
API objectString/ExpressionRequired. Select the API that you want to access in Twilio instance. This drop-down contains APIs (set of business objects) defined by Twilio. Programmable SMSAutopilot
EntityString/Expression/SuggestionRequired. Select an entity that belongs to the corresponding API object chosen above. 
For example, Messages entity belongs to the Programmable SMS API object. In this field, the available entities are dynamically populated in the suggestion drop-down list based on the selected API object.
You can choose an entity from the suggestion list dynamically or enter a static value. 
MessagesAssistant
Entity SIDString/Expression

Specify a unique ID for the entity that determines one specific resource under the given entity type.
If this field is left blank, by default all resources under the given entity type are retrieved. 

  • Certain Twilio entities represent uncountable resources that do not support SID-specified reading, for example, the 'Feedback' entities under several API objects. While, few Twilio entities do not support retrieving records without a SID, such as 'Dialogue' entity under the 'Autopilot' object. In this case, you must provide an Entity SID in this field. 
  • We recommend referring to Twilio's documentation or API explorer whenever you encounter the "Resource is not found" warning while performing the batch reading.
NoneSM191d7edflkj987enm236eee168
Required SIDs

Use this field set to define the parent entity String Identifiers (SIDs) necessary for accessing the requested resources, if any.

Twilio's API designs follow a hierarchical pattern to indicate relationships among entities. For example, you can build an autopilot assistant to answer incoming calls with a task model. In this case, the Task entity is considered as a parameter of Assistant entity. Each assistant has a unique SID, and one assistant can have multiple tasks associated with it. To retrieve the record for one of the tasks, you must provide the task's parent assistant SID in the Required SIDs table.

Click  to add a new row in this table and define the values accordingly. This field set contains the following fields:

  • SID name
  • SID value
SID nameString/Expression/Suggestion

Specify the name of the SID to call the API.  

NoneServiceSID
SID valueStringSpecify the SID value for the corresponding SID name chosen above.NoneUG12ab345acdeg9jkm345jkm765x
Filter parameters

Use this field set to define the names and values of query parameters for filtering the API responses. Click  to add a new row in this table and define the values accordingly.

This field set comprises the following fields:

  • Field name
  • Operator
  • Field value

For certain entities, you can provide Language or Date as the filter parameters; the input value format for these parameters should follow these standards:

Field NameString/Expression/Suggestion

Specify the parameter names to filter the results.

You must enter only allowed parameters in this field. Use the suggestion list to identify the allowed parameters.

The available options are:

  • From
  • To
  • DateSent
NoneDateSent
OperatorString/Expression

Select the operator from the drop-down list. The available options are:

  • equal to(=)
  • greater than or equal to(>=)
  • less than or equal to(<=)

The operators ">=" and "<=" are applicable only for sequential properties, such as the date and time-related parameters. for example, DateSent, DateCreated, StartTime, and EndTime.

=>=
Field ValueString/ExpressionSpecify the value for service operation fields. The data type of this field depends on the field name chosen which can be String, Integer, or DateTime.None2020-03-10T10:00-20:00
Output Fields Pagination Options

Use this field set to add advanced options to define the pagination parameters for API response.

This field set comprises the following fields:

  • Page size
  • NextURL

Page size

IntegerSpecify the number of records the Snap must get in each page. See Twilio Read#Pagination for more information.200500

Next URL

Expression/Drop-down list

Enter an expression that will be evaluated on the output document to a URL that the Snap must use to get the next page. This property is used for the pagination feature. The Next URL has two components, which are structured as follows:

("<endpoint_URL>" + $next_page_uri)

  • The first component comprises the URL of the endpoint . ("<endpoint_URL>").
  • The second component is a pointer to the parameter in the API response that contains the URL of the next page(s).
None"https://api.twilio.com/2010-04-01" + $next_page_uri"
Connection details

Use this field set to configure the network connection parameters.

This field set comprises the following fields:

  • Connection timeout
  • Maximum request attempts
  • Retry request interval

Connection timeout

IntegerRequired. Specify the connection timeout duration in seconds.3060

Maximum request attempts

IntegerRequiredSpecify the maximum number of connection attempts if the connection fails or is timed-out.36

Retry request interval

IntegerRequiredSpecify the time in seconds to wait before retrying the connection request.13
Snap ExecutionDropdown list

Specifies the execution type:

  • Validate & Execute: Performs limited execution of the Snap (up to 50 records) during Pipeline validation; performs full execution of the Snap (unlimited records) during Pipeline execution.

  • Execute only: Performs full execution of the Snap during Pipeline execution; does not execute the Snap during Pipeline validation.

  • Disabled: Disables the Snap and, by extension, its downstream Snaps.

Validate & ExecuteValidate & Execute

Troubleshooting

ErrorReasonResolution
The input entity does not exist.An invalid entity has been entered.

Click the suggestion drop-down list and select a valid entity.


One or more Required SIDs are missingThe required SIDs are mandatory for this Endpoint.Check your settings under the Required SID table. Ensure that you have entered SID names and values for all the entries.

You have an empty value in the Key/Value field.

The Field name field and Field value must not be empty for the Filter parameters.

Enter a valid key/value parameters (Field name field and Field value) for Filter parameters.


The Entity SID is missing. The Entity SID is mandatory for this Endpoint.Provide an Entity SID. Refer to Twilio Read Snap Settings for information on how to provide Entity SIDs.
The next page URL is illegal.The next page URL can only be obtained in the output document.Provide an expression in the Next URL field that will be evaluated on the output document to an URL, that the Snap must use to get the next page.

Pagination

By default, if no pagination parameters are provided, the Twilio API retrieves all the records under the given entity during batch reading. In the Read Snap, you can use the Page size field to limit the number of returned records in a single response. By default the Page size is set to 200. If the total amount of the target resources exceed the input Page size, the rest of the records are separated into the next pages of the designated size.

To get all the paginated records recursively, enter an expression in the Next URL field. The Next URL field of this Snap follows a similar format of the same field (Next URL) in Rest Get Snap, which should be structured as follows:
"<Twilio_Host_URL>" + $<next_page_url_path>, 

If you want to extract the <Twilio_Host_URL> from an upstream document, you can assign the JSON path referring to the host URL to the '$original' node in an expression.

For example, if you have the following JSON document as the input:

[
 {
  "twilioHostUrl": "https://api.twilio.com" 
 }
]

You can obtain the URL value by assigning the key "twilio_host_url" to the $original in the expression:

$original.twilio_host_url+ "=" + $next_page_uri

  • The second part $<next_page_url_path> should be an expression pointing to the JSON path in the API response that contains the other half of the URL with a page token in the query parameters for getting the next page. 

Examples

Reading Messages Sent Using Twilio Programmable SMS Service

In this example we use the Twilio Read Snap to retrieve messages sent with Programmable SMS services based on certain filter parameters and pagination options. This example assumes that you have configured and authorized a valid Twilio Account. See Twilio Account.

First, we configure the Twilio Read Snap as shown below to filter the messages on Phone number and Date sent. We also want to view these messages in two pages. 

  • API objectProgrammable SMS
  • Entity: Messages
  • Filter criteria: Messages sent from <$Phone number> and messages sent on date 2020-03-10T10:00-20:00
  • Page size: 2
  • Next URL: $original.Host+$next_page_url

A successful validation of this Snap generates a JSON array containing each page as an independent JSON object, as shown below. Expand one of the JSON objects and observe 2 messages present in the $messages array as specified in the Page Size field.

Also, note that there are 5 pages in total, with their page indexes marked under the $page node. 

At this point we bifurcate the pages into two different output views - the first two pages to the first output view and the remaining pages to the the second output view. So, we configure the Router Snap as shown below:

Finally, we add the JSON and XML Formatter Snaps connecting to the Router Snap where the diverted output ends.

We write the two outputs into files in different formats (XML and JSON) using a File Writer Snap. On successful execution, we see two files with the corresponding names, in the Project space. 

Download this Pipeline.

Downloads

Important Steps to Successfully Reuse Pipelines

  1. Download and import the Pipeline into SnapLogic.
  2. Configure Snap accounts as applicable.
  3. Provide Pipeline parameters as applicable.

Snap Pack History

 Click here to expand...
ReleaseSnap Pack VersionDateTypeUpdates
February 2024main170 LatestFixed security vulnerabilities in the Twilio Snap Pack.
February 2024main168 StableUpdated and certified against the current SnapLogic Platform release.
November 2023main155 StableUpdated and certified against the current SnapLogic Platform release.

August 2023

main138

 

Stable

Updated and certified against the current SnapLogic Platform release.

May 2023

main130 

Stable

Upgraded with the latest SnapLogic Platform release.

February 2023main114 StableUpgraded with the latest SnapLogic Platform release.
November 2022main113 StableUpgraded with the latest SnapLogic Platform release.
August 2022main111
 
StableUpgraded with the latest SnapLogic Platform release.
4.29main108
 
StableUpgraded with the latest SnapLogic Platform release.
4.28main100
 
StableUpgraded with the latest SnapLogic Platform release.
4.27main93
 
Stable

Upgraded with the latest SnapLogic Platform release.

4.26main88
 
Stable

Upgraded with the latest SnapLogic Platform release.

4.25main80
 
Stable

Upgraded with the latest SnapLogic Platform release.

4.24 Patch424 patch(main80)
 
Latest

Introduced the Twilio Snap Pack that enables you to perform various communication functions using its Web Service APIs. This Snap Pack offers the following Snaps:


See Also