<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://v2.okchat.ai/api/external/chatbot/{chatbotId}/voice-agent",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'agentId' => '5afe16ed-5fd2-4552-a993-903bc9c32bb6',
'appearance' => [
'backgroundColor' => '#ffffff',
'borderColor' => '#e1e1e1',
'buttonColor' => '#000000',
'buttonRadius' => 32,
'buttonTextColor' => '#ffffff',
'cardRadius' => 20,
'focusOutlineColor' => '#000000',
'textColor' => '#000000'
],
'avatar' => [
'imageUrl' => 'https://assets.grok.com/users/e473c4f6-e103-4d71-8194-03a7ecc74370/0R8nPXaAvhBinoUh-generated_image.jpg'
],
'model' => [
'max_output_tokens' => 2048,
'temperature' => 0.7
],
'text' => [
'callToAction' => 'Appointment?',
'endCall' => 'End',
'listeningStatus' => 'Listening',
'speakingStatus' => 'Talk to interrupt',
'startCall' => 'Start a call'
],
'vad' => [
'prefix_padding_ms' => 500,
'silence_duration_ms' => 1000,
'threshold' => 0.8
],
'voice' => 'shimmer'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}