-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanageWithCallLeg.ts
41 lines (35 loc) · 1.02 KB
/
manageWithCallLeg.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import {
getCallIdFromConfig,
initVoiceService,
} from '../../config';
import { Voice, VoiceRegion } from '@sinch/sdk-core';
(async () => {
console.log('*************************');
console.log('* ManageCallWithCallLeg *');
console.log('*************************');
const callId = getCallIdFromConfig();
const requestData: Voice.ManageWithCallLegRequestData = {
callId,
callLeg: 'callee',
manageWithCallLegRequestBody: {
instructions: [
{
name: 'say',
text: 'Hello, the call is over, hanging up now. Goodbye',
},
],
action: {
name: 'hangup',
},
},
};
const voiceService = initVoiceService();
voiceService.setRegion(VoiceRegion.EUROPE);
try {
await voiceService.calls.manageWithCallLeg(requestData);
} catch (error) {
console.log(`Impossible manage with call leg the call Id ${requestData.callId}`);
throw error;
}
console.log(`The call '${requestData.callId}' has been managed successfully with a call leg`);
})();