Menu

Expand
Rate this page:

Query

Twilio Autopilot's Query API resource is the endpoint where Autopilot's natural language understanding analysis is performed.

The Query endpoint takes your user's natural language input (text or speech) and returns structured JSON output with the results.

This resource can behave in two different ways:

  1. It can be used in a RESTful manner, where POSTing creates a Query instance resource which logs the query that can be reviewed and used as additional training data if posted as a tagged Sample.
  2. It can also be used in an "ephemeral" mode, where POSTs to the Query resource returns results, but do not create a Query instance resource. You can specify whether to log the queries or not in the LogQuery property of an Assistant.

End-user queries can be a great source of training data. The Query resource not only enables you to log Queries but also keep track of whether a query was already reviewed and used as a Sample or not by updating the status and sample_sid fields.

Samples are not created automatically from Queries. You have to determine the task and tag the Sample with the Fields to create the Sample.

All Autopilot REST API resources use the following base URL:

https://autopilot.twilio.com/v1

Query properties

Resource Properties in REST API format
account_sid
sid<AC> Not PII

The SID of the Account that created the Query resource.

date_created
date_time<iso8601> Not PII

The date and time in GMT when the resource was created specified in RFC 2822 format.

date_updated
date_time<iso8601> Not PII

The date and time in GMT when the resource was last updated specified in RFC 2822 format.

results
object Not PII

The natural language analysis results that include the Task recognized and a list of identified Fields.

language
string Not PII

The ISO language-country string that specifies the language used by the Query. For example: en-US.

model_build_sid
sid<UG> Not PII

The SID of the Model Build queried.

query

The end-user's natural language input.

sample_sid
sid<UF> Not PII

The SID of an optional reference to the Sample created from the query.

assistant_sid
sid<UA> Not PII

The SID of the Assistant that is the parent of the resource.

sid
sid<UH> Not PII

The unique string that we created to identify the Query resource.

status
string Not PII

The status of the Query. Can be: pending-review, reviewed, or discarded

url
url Not PII

The absolute URL of the Query resource.

source_channel
string Not PII

The communication channel from where the end-user input came.

dialogue_sid
sid<UK> Not PII

The SID of the Dialogue.

Create a Query resource

post
https://autopilot.twilio.com/v1/Assistants/{AssistantSid}/Queries

Creates a Query against the Model Build for the Assistant identified by {AssistantSid}.

Parameters
Parameters in REST API format
assistant_sid
Path
post sid_like<UA> Not PII

The SID of the Assistant that is the parent of the new resource.

language
Required
post string Not PII

The ISO language-country string that specifies the language used for the new query. For example: en-US.

query
Required
post string PII MTL: 30 DAYS

The end-user's natural language input. It can be up to 2048 characters long.

tasks
Optional
post string Not PII

The list of tasks to limit the new query to. Tasks are expressed as a comma-separated list of task unique_name values. For example, task-unique_name-1, task-unique_name-2. Listing specific tasks is useful to constrain the paths that a user can take.

model_build
Optional
post sid_like<UG> Not PII

The SID or unique name of the Model Build to be queried.

Example 1
Loading Code Sample...
        
        

        Create: Perform a Query against a Model Build

        Fetch a Query resource

        get
        https://autopilot.twilio.com/v1/Assistants/{AssistantSid}/Queries/{Sid}

        Returns the Query instance identified by {QuerySid}.

        Parameters
        Parameters in REST API format
        assistant_sid
        Path
        get sid_like<UA> Not PII

        The SID of the Assistant that is the parent of the resource to fetch.

        sid
        Path
        get sid_like<UH> Not PII

        The Twilio-provided string that uniquely identifies the Query resource to fetch.

        Example 1
        Loading Code Sample...
              
              

              Fetch a Query

              Read multiple Query resources

              get
              https://autopilot.twilio.com/v1/Assistants/{AssistantSid}/Queries

              Returns a list of Queries for this Assistant. The list returned includes paging information.

              Parameters
              Parameters in REST API format
              assistant_sid
              Path
              get sid_like<UA> Not PII

              The SID of the Assistant that is the parent of the resources to read.

              language
              Optional
              get string Not PII

              The ISO language-country string that specifies the language used by the Query resources to read. For example: en-US.

              model_build
              Optional
              get sid_like<UG> Not PII

              The SID or unique name of the Model Build to be queried.

              status
              Optional
              get string Not PII

              The status of the resources to read. Can be: pending-review, reviewed, or discarded

              dialogue_sid
              Optional
              get sid<UK> Not PII

              The SID of the Dialogue.

              Example 1
              Loading Code Sample...
                    
                    

                    Read: List all Queries for an Assistant

                    Update a Query resource

                    post
                    https://autopilot.twilio.com/v1/Assistants/{AssistantSid}/Queries/{Sid}

                    Updates the Query identified by {QuerySid}.

                    Parameters
                    Parameters in REST API format
                    assistant_sid
                    Path
                    post sid_like<UA> Not PII

                    The SID of the Assistant that is the parent of the resource to update.

                    sid
                    Path
                    post sid_like<UH> Not PII

                    The Twilio-provided string that uniquely identifies the Query resource to update.

                    sample_sid
                    Optional
                    post sid<UF> Not PII

                    The SID of an optional reference to the Sample created from the query.

                    status
                    Optional
                    post string Not PII

                    The new status of the resource. Can be: pending-review, reviewed, or discarded

                    Example 1
                    Loading Code Sample...
                          
                          

                          Update a Query

                          Delete a Query resource

                          delete
                          https://autopilot.twilio.com/v1/Assistants/{AssistantSid}/Queries/{Sid}
                          Parameters
                          Parameters in REST API format
                          assistant_sid
                          Path
                          delete sid_like<UA> Not PII

                          The SID of the Assistant that is the parent of the resources to delete.

                          sid
                          Path
                          delete sid_like<UH> Not PII

                          The Twilio-provided string that uniquely identifies the Query resource to delete.

                          Example 1
                          Loading Code Sample...
                                
                                

                                Delete a Query

                                Rate this page:

                                Need some help?

                                We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

                                Loading Code Sample...
                                      
                                      
                                      

                                      Thank you for your feedback!

                                      Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

                                      Sending your feedback...
                                      🎉 Thank you for your feedback!
                                      Something went wrong. Please try again.

                                      Thanks for your feedback!

                                      thanks-feedback-gif