メニュー

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?

よくある質問

How can I get the user's phone number in Autopilot?

Autopilot sends the user's phone number as a parameter (UserIdentifier) of the Task's HTTP Callback.

You can find all the parameters Autopilot sends here:

https://www.twilio.com/docs/autopilot/actions/autopilot-request

Is it possible to access the user's phone number as a variable of the Actions JSON in the Actions Bin?

Unfortunately not at this point. If you need the user's phone number you have to configure the Task with an HTTP Callback and get it as a parameter of that request in your application or Twilio Function.

Can Autopilot initiate outbound calls?

Autopilot itself does not initiate outbound calls, but you can use our Programmable Voice API in combination with Autopilot to have Autopilot handle the call.

1 ) Make an outbound call using our Programmable Voice Calls API. You can learn more about making outbound calls with this tutorial.

2) Set the Url of the outbound call to the Autopilot's Programmable Voice URL

Autopilot Console -> Your Assistant -> Channels -> Programmable Voice

Copy Autopilot's Programmable Voice Url and use that as the Outbound call Url parameter.

3) Make a call. This way when you make a call via API, as soon as it is answered it will point to Autopilot to handle the call.

Can I use Autopilot with Studio with Voice?

Yes, you can. However, we don't have a Studio widget yet so please follow the steps below to set up Studio and Autopilot for Voice.

Sending a call from Studio to Autopilot

To send a call from a Studio flow to Autopilot you need to have a Twilio Function widget that redirects the call to Autopilot. We'll walk you through step by step.

1) You need to add a Say/Play Widget, a Function Widget where you redirect the call, a Play/Say that will be skipped, and a Play Say where the call will land when it is handedoff back from Autopilot. Call the Function widget transfer-to-autopilot.

Studio to Autopilot

2) Open a new tab and go to the Twilio Functions section. Then create a new function with a Blank template and call it transfer-to-autopilot with path: transfer-to-autopilot.

3) Paste this code in the function

exports.handler = function(context, event, callback) {
	const client = context.getTwilioClient();
	client.calls(event.CallSid)
      .update({method: 'POST', url: 'REPLACE_THIS'})
      .then(call => { 
          console.log(call.to);
          callback(null);
      })
      .catch(error => console.log(error));	
};

4) Replace the Url on line 5 with your Autopilot's Programmable Voice URL that you can find at:

Autopilot Console -> Your Assistant -> Channels -> Programmable Voice

5) Deploy the Twilio Function

6) Go back to Studio and hit reload. Go to the transfer-to-autopilot function widget and select the "transfer-to-autopilot" function.

Then we need to pass the CallSid to the function so that the function can modify the call.

  • Click the transfer-to-autopilot widget
  • Go to 'Config' on the right-hand side.
  • Click to Add a Function Parameter, and add the following values
  • Key: CallSid
  • Value: {{trigger.call.CallSid}}
  • Click save.

7) Point a number to your Studio Flow if you haven't done so yet and give it a call. Once you get to the transfer-to-autopilot widget you should be transferred to your Autopilot Assistant!

Sending a Call from Autopilot to Studio

Sending a call from Autopilot back to Studio is also possible following the steps below:

1) Go to the Autopilot Console and select your Assistant.

2) Select the task where you want to handoff back to Studio

3) Copy the following Actions JSON on that task

{
	"actions": [
		{
			"handoff": {
			    "channel":"voice",
			    "uri":"https://webhooks.twilio.com/v1/Accounts/{ACCOUNT_SID}/Flows/{FLOW_SID}?FlowEvent=audioComplete",
			    "method":"POST"
			}
		}
	]
}

4) Replace your AccountSid and FlowSid on the URL.

IMPORTANT THINGS TO NOTE:

  • The transfer-to-autopilot function cannot be the first widget right after the call trigger because we can not modify a call that has not been answered yet.
Rate this page:

ヘルプが必要ですか?

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.