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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.