To make the Autopilot assistant request, your application needs to make an HTTP POST request to Twilio’s Autopiliot Custom Channel API with 3 required pieces of information; user id, text message, and setting "en-US" to indicate that this is the language being used.
UserId
: Free format string to identify the user making the request. This will be used by Autopilot for Dialogue and state management.Text
: The user's text input, such as "Hello".Language
: language for the exchange. This should always be "en-US".
Warning: Autopilot currently only supports US English. We do not have plans to add support for additional languages at this time.
Sample Code
Here's an example cURL for starting an Autopilot dialogue using Autopilot Custom Channel:
curl -XPOST https://channels.autopilot.twilio.com/v2/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/UAXXXXXXXXXXXXXXX/custom/{channel reference string} \
--user '[YOUR ACCOUNT_SID]:[YOUR AUTH_TOKEN]\
--data-urlencode 'UserId=David' \
--data-urlencode 'Text="Hello"' \
--data-urlencode 'Language=en-US'
This example will make an API request to your Autopilot assistant. The POST response will be in the JSON format and include the content to display back to the user.
To make this curl script work for you:
- Line 1 update with your Account SID, assistant SID, and a unique name for your channel.
- Line 2 update the user parameter in curl with your Account SID and Auth Token. This will generate the authorization basic header that is required.
- Line 3 update with a userid to indicate who is interacting with your Autopilot assistant.
- Line 4 update with the text you want to send to the assistant.
- Line 5 ensure that the Language is set to "en-US".
For full details on each of the available options, please see Autopilot: Custom Channel (Twilio Docs).