Добавление записи звонка при исходящем звонке, с меткой через какой номер звонили.

const axios = require('axios');

module.exports = async (args) => {
	
	const contact_id = args.context.contact_id; 
	const contact_name = args.context.contact_name; 
	const contactResponsibleId = args.context.contact_responsible_id;
	const call_started_user_id = args.context.call_started_user_id.id;
	const call_started_user_id_name = args.context.call_started_user_id.name;
	const line_number = args.call_args.line_number;

	// пишем звонок
	const url = `https://${args.settings.domain}/api/v2/notes`;
	const headers = {
		'Content-Type': 'application/json',
		'Authorization': `Bearer ${args.crm_auth}`,
	};
	const data = {
		add: [{
			element_id: parseInt(contact_id),
			element_type: 1, // 1 - Contact, 2 - Lead, 3 - Company
			note_type: 11, // 10 - Incoming call, 11 - Outgoing call
			params: {
				UNIQ: args.call_args.call_id,
				LINK: args.call_args.call_record_link,
				PHONE: `${args.call_args.dst_num}  ` + 'Через номер: ' + `${line_number} `,
				DURATION: parseInt(args.call_args.timestamp) - parseInt(args.call_args.call_answer_timestamp),
				SRC: 'Sipuni',
				call_status: 4, //1 Left a voice message, 2 Call back later, 3 Not available, 4 The conversation took place, 5 Wrong number, 6 Did not get through, 7 Number is busy
				call_result: '',
			},
			created_by: parseInt(call_started_user_id),
			responsible_user_id: parseInt(contact_responsible_id),
		}]
	};
	const call = await axios.post(url, data, { headers });
	const noteId = call.data._embedded.items[0].id;

	return {
		contact_id,
		contact_name,
		noteId,
		call_started_user_id,
		call_started_user_id_name,
		contact_responsible_id,

	};
};