-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate.ts
46 lines (40 loc) · 1.26 KB
/
create.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
import { Conversation } from '@sinch/sdk-core';
import {
getMessengerTokenFormConfig,
getPrintFormat,
initConversationService,
printFullResponse,
} from '../../config';
(async () => {
console.log('*****************');
console.log('* App_CreateApp *');
console.log('*****************');
const messengerToken = getMessengerTokenFormConfig();
const requestData: Conversation.CreateAppRequestData = {
appCreateRequestBody: {
display_name: 'New app created with the Node.js SDK',
channel_credentials: [
{
channel: 'MESSENGER',
static_token: {
token: messengerToken,
},
},
],
conversation_metadata_report_view: 'FULL',
retention_policy: {
retention_type: 'CONVERSATION_EXPIRE_POLICY',
ttl_days: 60,
},
},
};
const conversationService = initConversationService();
const response = await conversationService.app.create(requestData);
const printFormat = getPrintFormat(process.argv);
if (printFormat === 'pretty') {
console.log(`New app created with the id '${response.id}'`);
} else {
printFullResponse(response);
}
console.log(`You may want to update your .env file with the following value: CONVERSATION_APP_ID=${response.id}`);
})();