Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now


Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Twilio Autopilot CLI

The Twilio Autopilot CLI is a command line interface for managing Twilio Autopilot. After installing you'll be able to:

  • Create an assistant from a template.
  • Export an existing assistant to a JSON schema file.
  • Update an existing assistant with a JSON schema file.
  • Delete an assistant.
  • Simulate an Assistant.
  • Import a DialogFlow Agent into Autopilot.
  • Bulk upload Field values.

The Autopilot CLI enables you to:

  • Keep your assistant in a repository with version control.
  • Integrate with your CI environment.
  • Share schema files and collaborate on development.

Installing the Autopilot CLI

sudo npm install -g @twilio/autopilot-cli

CLI commands and usage

  ta init --account <account-sid> --token <auth-token> [--credentials <name>]
  ta list [--credentials <name>]
  ta create [--schema <file>] [--credentials <profile-name>]
  ta update --schema <file> [--credentials <name>]
  ta delete --assistant <assistant-sid> [--credentials <name>]
  ta export --assistant <assistant-sid> [--credentials <name>]
  ta import --dfbackup <dialogflow-backup-zip-file> --dfagent <dialogflow-agent-name> [--credentials <name>]
  ta simulate --assistant <assistant-sid> --text <user-text-input> [--credentials <name>]
  ta field --assistant <assistant-sid> --field <field-type-sid or field-type-unique-name> --csv <csv-file> [--credentials <name>]

  -h --help             Help Screen
  -v --version          CLI Version
  --account             Twilio Account SID
  --token               Twilio Auth Token
  --schema              Autopilot Schema File/DialogFlow Schema Zip File 
  --assistant           Twilio Autopilot Assistant SID
  --dfagent             Dialogflow Agent Name
  --dfbackup            Dialogflow Agent Backup Zip File
  --text                The user text input
  --field               Twilio Autopilot Field Type SID
  --csv                 CSV File path

You can test Assistant behavior in the command line using ta simulate and create new Fields using ta field.

Configuring the Autopilot CLI

To invoke the Autopilot CLI, use the ta command.

If it's your first time using the CLI, you need to configure a Twilio Account SID and Auth Token. Optionally, multiple accounts can be configured using the --credentials option to associate an Account SID and Auth Token with a profile name. To configure the CLI with your Twilio credentials run the following command: $ ta init. Credentials will be saved in a local JSON file in ~/.twilio/config.json.

The first set of credentials you provide will become your 'default' profile. You can create additional profiles for different sets of credentials or update an existing profile by running the following command: $ ta init --credentials test-profile (where 'test-profile' the the profile name you'd like to add/update).

Schema files

A schema file is a JSON document that defines the behavior of an Autopilot assistant. It contains the Tasks, Samples, Actions, Fields, Field Types, Field Values as well as it's Defaults and Stylesheet. Schema files can be created using the ta create command or by exporting existing Assistants created using the Twilio console or the API with the ta export command. You can directly edit a schema file and use the ta update command to update the Assistant.

You can find a few example schema files in Autopilot Templates repo on GitHub.

Importing Dialogflow Agents

The ta import command lets you create Autopilot Assistants using existing DialogFlow Agents. After you export an Agent into a ZIP file by following the instructions in the Dialogflow documentation, pass the ZIP file to the ta import command to create an Autopilot Assistant.

  • Intents, Training Phrases and Responses in Dialogflow are converted to Tasks, Samples and Say Actions in Autopilot.
  • Developer Entities in Dialogflow are converted to custom Field Types in Autopilot.
  • Certain System Entities in Dialogflow are converted into Built-in Field Types in Autopilot as defined in the CLI documentation.
  • Dialogflow Contexts are not currently imported to Autopilot.
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 browsing the Twilio tag on Stack Overflow.