Abbreviated php webhook code below. API is V2.7.1 PHP is version 7. In the call.initiated event, it verifies that direction = incoming, retrieves the call object, and attempts to answer the call. call.answer() throws "(Code 90102) Can not issue an answer command on an outbound call".
The same logic flow is given as one of the python examples. What is it I don't know?
if ($event=='call.initiated') { $direction = $payload['direction']; if ($direction=="incoming") { $to = $payload['to']; if ($to==$TelnyxVoxNumber1) { $connectionId = $payload["connection_id"]; $callControlId = $payload["call_control_id"]; $call = \Telnyx\Call::retrieve($callControlId); error_log("Group5VoiceHook.php CALL: " . print_r($call, true)); $call->answer(); $call->transfer(['id' => $connectionId, 'to' => $transferNumber]); }
} }