-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate.ts
52 lines (46 loc) · 1.26 KB
/
update.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
42
43
44
45
46
47
48
49
50
51
52
import {
getCallIdFromConfig,
initVoiceService,
} from '../../config';
import { Voice, VoiceRegion } from '@sinch/sdk-core';
(async () => {
console.log('**************');
console.log('* UpdateCall *');
console.log('**************');
const callId = getCallIdFromConfig();
const requestData: Voice.UpdateCallRequestData = {
callId,
updateCallRequestBody: {
instructions: [
{
name: 'sendDtmf',
value: '1234#',
},
{
name: 'startRecording',
options: {
destinationUrl: 's3://sinch-storage/voice-recordings/my-recording.mp3',
credentials: '(AwsAccessKey):(AwsSecretKey):(AwsRegion)',
notificationEvents: true,
transcriptionOptions: {
enabled: true,
locale: 'en-US',
},
},
},
],
action: {
name: 'hangup',
},
},
};
const voiceService = initVoiceService();
voiceService.setRegion(VoiceRegion.EUROPE);
try {
await voiceService.calls.update(requestData);
} catch (error) {
console.log(`Impossible update the call Id '${requestData.callId}'`);
throw error;
}
console.log(`The call '${requestData.callId}' has been updated successfully`);
})();