2

I'm trying to send optional parameters to a Twilio Studio Flow Trigger using PHP. I followed the example shown in the Twilio Studio REST API docs and was successful triggering a new Flow using the (required) sender and recipient phone numbers.

use Twilio\Rest\Client;
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "my_auth_token";
$twilio = new Client($sid, $token);
$execution = $twilio->studio->v1->flows("FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                ->executions
                                ->create("+15555559876", "+15555551234");

After getting the basic communications working, I now want to pass a couple parameters to the Flow. Unfortunately, I couldn't find any PHP examples that include optional parameters. (The docs mention how to access parameter values in the widgets with {{flow.data.parameterName}}, but not how to generate the request in PHP.)

The answer is probably easy and obvious but I can't figure it out and would appreciate any guidance.

Spaeder
  • 61
  • 5

1 Answers1

4

Received an answer from Twilio Support.

$data = ["parameters" => ["foo" => "bar"]];
$flow = $twilio->studio->v2->flows("FWxxxxx");
$flow->executions->create($to, $from, $data);

Optional parameters are now passing through and can be used by widgets in the Studio Flow.

miken32
  • 42,008
  • 16
  • 111
  • 154
Spaeder
  • 61
  • 5