Adding INAPI example
This commit is contained in:
39
Integrations/Global Variables/INAPI.js
Normal file
39
Integrations/Global Variables/INAPI.js
Normal file
@@ -0,0 +1,39 @@
|
||||
return {
|
||||
post(ani, dnis, agent, userData) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const OIDC = await CAInterface().getOIDC()
|
||||
let config = CAInterface().settings().url.CA
|
||||
const inapiURL = `https://${config.base}/interaction-notifier/${config.tenant}/notifications`
|
||||
|
||||
const { data } = await CAInterface().axios('inapi', {
|
||||
method: 'post',
|
||||
url: inapiURL,
|
||||
headers: {
|
||||
'Content-Type': 'application/ld+json',
|
||||
Authorization: `OIDC_id_token ${OIDC.access_token}`,
|
||||
},
|
||||
data: {
|
||||
'@type': 'vin:InteractionNotification',
|
||||
'vin:target': {
|
||||
'@type': 'vemorg:Agent',
|
||||
'so:identifier': agent,
|
||||
},
|
||||
'vin:interaction': {
|
||||
'@type': 'vin:InboundTelephonyInteraction',
|
||||
'vin:dnis': dnis,
|
||||
'vin:cli': ani,
|
||||
'vin:userData': userData,
|
||||
},
|
||||
},
|
||||
})
|
||||
console.log({
|
||||
inapiresult: data,
|
||||
})
|
||||
resolve()
|
||||
} catch (error) {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user