-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddUnsortedSip.js
40 lines (33 loc) · 2.11 KB
/
addUnsortedSip.js
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
// const {AmoApiClient} = require('@mobilon/amotop');
const {AmoApiClient} = require('../../dist');
const {domain, accessToken, debug} = require('../_config');
const amoApiClient = new AmoApiClient(domain, accessToken, {debug});
const start = async () => {
try {
const params = {
source_uid: '32542345235',
source_name: 'mmmm',
metadata: {
from: '324234523534', //!!!! передаем в from, обратно получим в phone
phone: '79135292926',
call_responsible: '7495000000', // string|int|null Кому сделан звонок
// Можно передавать ID пользователя amoCRM, номер телефона или имя.
called_at: Math.floor(new Date().getTime() / 1000), // int Когда сделан звонок в формате Unix Timestamp.
duration: 301, // int Сколько длился звонок
link: 'https://records.storage.com/345345345345', // string Ссылка на запись звонка
service_code: 'mobilon_vpbx', // string Код сервиса, через который сделан звонок
is_call_event_needed: true, // bool Данный флаг не возвращается в API, но может быть передан.
// В случае передачи значения true, в карточку будет добавлено событие о входящем звонке.
uniq: Math.random(), // string
},
};
console.log('params', params);
const data = await amoApiClient.addUnsortedSip([params]);
console.log('response', JSON.stringify(data));
const unsortedLeads = await amoApiClient.getUnsorted();
console.log('unsortedLeads', JSON.stringify(unsortedLeads, null, 2));
} catch (err) {
console.log('err', JSON.stringify(err.response.data, null, 2));
}
}
(start)();