Zadarma IP Telephony Integration on Website
Zadarma is an international IP telephony provider with virtual PBX (ZCRM), numbers in 100+ countries and WebRTC client for browser. A good option for companies with international clients.
Webhook Notifications
Route::post('/webhooks/zadarma', function (Request $request) {
// Signature verification
$data = $request->except('sign');
ksort($data);
$sign = md5(http_build_query($data) . env('ZADARMA_SECRET'));
if ($request->sign !== $sign) return response('Invalid sign', 403);
$event = $data['event'];
switch ($event) {
case 'NOTIFY_START':
// Incoming call
$caller = $data['caller_id'];
$this->handleIncomingCall($caller);
break;
case 'NOTIFY_END':
// Call completed
CallLog::create([
'zadarma_callid' => $data['call_id_with_rec'],
'caller' => $data['caller_id'],
'duration' => $data['duration'],
'disposition' => $data['disposition'] // answered | noanswer | busy
]);
break;
case 'NOTIFY_RECORD':
// Recording ready
$recordingUrl = $data['link'];
CallLog::where('zadarma_callid', $data['call_id_with_rec'])
->update(['recording_url' => $recordingUrl]);
break;
}
});
API — Callback Initiation
// Zadarma REST API v1
$params = [
'from' => $agentPhone, // phone number in Zadarma system
'to' => $customerPhone,
'sip_id' => env('ZADARMA_SIP_ID')
];
ksort($params);
$sign = base64_encode(hash_hmac(
'sha1',
env('ZADARMA_KEY') . urldecode(http_build_query($params)) . md5(serialize($params)),
env('ZADARMA_SECRET')
));
Http::withHeaders([
'Authorization' => env('ZADARMA_KEY') . ':' . $sign
])->get('https://api.zadarma.com/v1/request/callback/', $params);
WebRTC Call from Browser
Zadarma provides a WebRTC library for calls directly from the browser:
<script src="https://my.zadarma.com/webphoneApi/v3/js/zadarmawebrtc.js"></script>
<script>
var webrtcPhone = new ZadarmaWebRTC({
sipId: '{{ $sipId }}',
sipPass: '{{ $sipPassword }}',
onCallStateChange: function(state, data) {
console.log('Call state:', state);
}
});
webrtcPhone.dial('79001234567');
</script>
Getting Recordings
// Download call recording
$response = Http::get('https://api.zadarma.com/v1/pbx/record/request/', [
'call_id' => $zadarmaCallId,
'pbx_call_id'=> $pbxCallId
]);
$downloadUrl = $response->json()['link'];
Integration timeline: 2–3 days for full integration with webhooks and click-to-call.







