You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By passing a `port` to the `createServer` method, you receive a `Promise<WebhookServer>`.
355
+
After the server has been instantiated, you can subscribe to various `Events` (`NewCallEvent`,`AnswerEvent`,`HangupEvent`,`DataEvent`) which are described below.
356
+
357
+
#### Subscribing to _newCall_ events
358
+
359
+
After creating the server, you can subscribe to newCall events by passing a callback function to the `.onNewCall` method. This callback function will receive a `NewCallEvent` (described below) when called and expects a valid XML response to be returned.
360
+
To receive any further `Events`, you can subscribe to them with the following XML:
361
+
**Keep in mind:** you have to replace `https://www.sipgate.de/` with your server URL
You can return different `XML-Responses` in your callback, which will be passed to the PUSH-API:
393
+
394
+
##### Redirecting a call:
395
+
396
+
You can redirect the call to a specific phone number using the following XML:
397
+
398
+
```xml
399
+
<?xml version="1.0" encoding="UTF-8"?>
400
+
<Response>
401
+
<Dial>
402
+
<Number>4915799912345</Number>
403
+
</Dial>
404
+
</Response>
405
+
```
406
+
407
+
##### Sending a call to the voicemail:
408
+
409
+
Redirecting a call to the voicemail can be achieved by using the following XML snippet:
410
+
411
+
```xml
412
+
<?xml version="1.0" encoding="UTF-8"?>
413
+
<Response>
414
+
<Dial>
415
+
<Voicemail />
416
+
</Dial>
417
+
</Response>
418
+
```
419
+
420
+
##### Supressing your phone number and redirecting the call
421
+
422
+
The snippet mentioned below supresses your phone number and redirects you to a different number:
423
+
424
+
```xml
425
+
<?xml version="1.0" encoding="UTF-8"?>
426
+
<Response>
427
+
<Dialanonymous="true">
428
+
<Number>4915799912345</Number>
429
+
</Dial>
430
+
</Response>
431
+
```
432
+
433
+
##### Set custom callerId and redirect the call
434
+
435
+
The custom `callerId` can be set to any validated number in your sipgate account:
436
+
437
+
```xml
438
+
<?xml version="1.0" encoding="UTF-8"?>
439
+
<Response>
440
+
<DialcallerId="492111234567">
441
+
<Number>4915799912345</Number>
442
+
</Dial>
443
+
</Response>
444
+
```
445
+
446
+
##### Playing a sound file
447
+
448
+
**Please note:** Currently the sound file needs to be a mono 16bit PCM WAV file with a sampling rate of 8kHz. You can use conversion tools like the open source audio editor Audacity to convert any sound file to the correct format.
449
+
450
+
```xml
451
+
<?xml version="1.0" encoding="UTF-8"?>
452
+
<Response>
453
+
<Play>
454
+
<Url>http://example.com/example.wav</Url>
455
+
</Play>
456
+
</Response>
457
+
```
458
+
459
+
##### Gathering DTMF sounds
460
+
461
+
**Please note:** If you want to gather DTMF sounds, no future `onAnswer` and `onHangup` events will be pushed for the specific call.
After creating the server, you can subscribe to onAnswer events by passing a callback function to the `.onAnswer` method. This callback function will receive a `AnswerEvent` (described below) when called and expects nothing to be returned.
504
+
To receive this event you have to subscribe to them with the XML mentioned in [Subscribing to **newCall** Events](#subscribing-to-newcall-events)
505
+
506
+
```typescript
507
+
interfaceAnswerEvent {
508
+
callId:string;
509
+
direction:Direction;
510
+
from:string;
511
+
to:string;
512
+
xcid:string;
513
+
event:EventType.ANSWER;
514
+
user:string;
515
+
userId:string;
516
+
fullUserId:string;
517
+
answeringNumber:string;
518
+
diversion?:string;
519
+
}
520
+
```
521
+
522
+
#### Subscribing to _data_ events
523
+
524
+
After creating the server, you can subscribe to onData events by passing a callback function to the `.onData` method. This callback function will receive a `DataEvent` (described below) when called and expects nothing to be returned.
525
+
To receive this event you have to subscribe to them with the XML mentioned in [Subscribing to **newCall** Events](#subscribing-to-newcall-events)
526
+
527
+
```typescript
528
+
interfaceDataEvent {
529
+
callId:string;
530
+
event:EventType.DATA;
531
+
dtmf:string;
532
+
}
533
+
```
534
+
535
+
#### Subscribing to _hangup_ events
536
+
537
+
After creating the server, you can subscribe to onHangup events by passing a callback function to the `.onHangup` method. This callback function will receive a `HangupEvent` (described below) when called and expects nothing to be returned.
538
+
To receive this event you have to subscribe to them with the XML mentioned in [Subscribing to **newCall** Events](#subscribing-to-newcall-events)
539
+
540
+
```typescript
541
+
enumHangupCause {
542
+
NORMAL_CLEARING='normalClearing',
543
+
BUSY='busy',
544
+
CANCEL='cancel',
545
+
NO_ANSWER='noAnswer',
546
+
CONGESTION='congestion',
547
+
NOT_FOUND='notFound',
548
+
FORWARDED='forwarded',
549
+
}
550
+
551
+
interfaceHangupEvent {
552
+
callId:string;
553
+
direction:Direction;
554
+
from:string;
555
+
to:string;
556
+
xcid:string;
557
+
event:EventType.HANGUP;
558
+
cause:HangupCause;
559
+
answeringNumber:string;
560
+
}
561
+
```
562
+
322
563
### Contacts
323
564
324
565
The contacts module provides the following functions:
0 commit comments