Adding INAPI example
This commit is contained in:
parent
d0d9237486
commit
877118d038
@ -0,0 +1 @@
|
||||
{"file":{"content":{"intents":[],"alternates":[],"entities":[],"entityValues":[],"conversationFlows":[],"globalVariables":[{"_id":"4d5df90a-66f1-48b1-9762-7d76c888d153-NjgwMTdiMDhkODY5NzFiMzIzMGY1MzVl","workspaceId":"4d5df90a-66f1-48b1-9762-7d76c888d153-NjdiY2E4NjIyMTAwNzE2MjdkMzJlZjEy","name":"INAPI","type":"Function","content":"return {\n post(ani, dnis, agent, userData) {\n return new Promise(async (resolve, reject) => {\n try {\n const OIDC = await CAInterface().getOIDC();\n let config = CAInterface().settings().url.CA;\n const inapiURL = `https://${config.base}/interaction-notifier/${config.tenant}/notifications`;\n\n const { data } = await CAInterface().axios(\"inapi\", {\n method: \"post\",\n url: inapiURL,\n headers: {\n \"Content-Type\": \"application/ld+json\",\n Authorization: `OIDC_id_token ${OIDC.access_token}`,\n },\n data: {\n \"@type\": \"vin:InteractionNotification\",\n \"vin:target\": {\n \"@type\": \"vemorg:Agent\",\n \"so:identifier\": agent,\n },\n \"vin:interaction\": {\n \"@type\": \"vin:InboundTelephonyInteraction\",\n \"vin:dnis\": dnis,\n \"vin:cli\": ani,\n \"vin:userData\": userData,\n },\n },\n });\n console.log({\n inapiresult: data,\n });\n resolve();\n } catch (error) {\n reject(error);\n }\n });\n },\n};","parameters":"","returnsContextObject":false,"organizationId":"4d5df90a-66f1-48b1-9762-7d76c888d153-NjRjMmJhMGQ5NDdkMGM3OWY0YjlkN2Ey","metadata":{"createdBy":"4d5df90a-66f1-48b1-9762-7d76c888d153-NjRiYWMwNTkyNGE5YzU3ODNlZjc0MjRl","createdAt":1744924338236,"_vc":{"branch":"current","operation":"update","_id":"4d5df90a-66f1-48b1-9762-7d76c888d153-NjgwMTZlYjJkODY5NzFiMzIzMGY1MzU1","lts_id":"4d5df90a-66f1-48b1-9762-7d76c888d153-NjgwMTdiNzk4YzllYjA3MzRjMjcyNzQ1","commitId":"4d5df90a-66f1-48b1-9762-7d76c888d153-NjgwMTdiNzlkODY5NzFiMzIzMGY1MzVm"},"updatedBy":"4d5df90a-66f1-48b1-9762-7d76c888d153-NjRiYWMwNTkyNGE5YzU3ODNlZjc0MjRl","updatedAt":1744927609557}}],"proxyScripts":[],"dynamicQueries":[],"widgets":[]},"authorId":"4d5df90a-66f1-48b1-9762-7d76c888d153-NjRiYWMwNTkyNGE5YzU3ODNlZjc0MjRl","description":"Interaction Notification API is used to push Call Pops into Channel Automation.","readme":"### Interaction Notification API\n\nInteraction Notification API is used to push Call Pops into Channel Automation.\n\n#### Prerequisits\n\nInstall the Channel Automation Hub Package\n\nConversation Flow Code Block Example:\n\n```javascript\n(async () => {\n const ani = recognizedObject.metadata.ani;\n const dnis = recognizedObject.metadata.dnis;\n const firstName = conversationData.customer?.firstName ?? \"FirstName\";\n const lastName = conversationData.customer?.lastName ?? \"LastName\";\n const studentId = conversationData.customer?.studentId ?? \"StudentId\";\n const dob = conversationData.customer?.dob ?? \"1/1/1970\";\n INAPI().post(`${ani}`, `${dnis}`, \"ccmary\", {\n \"@type\": \"ved:TelephonyCallDataED\",\n \"ved:firstName\": `${firstName}`,\n \"ved:lastName\": `${lastName}`,\n \"ved:studentId\": `${studentId}`,\n \"ved:dob\": `${dob}`,\n });\n})()\n .catch((error) => {\n console.log(error.message);\n recognizedObject.answers.push(\"\");\n recognizedObject.errorInfo = {\n ...recognizedObject.errorInfo,\n label: {\n data: error.toJSON ? error.toJSON() : {},\n message: error.message,\n },\n };\n })\n .finally(() => {\n next();\n });\n```","entities":{"Widget":[],"Dashboard":[],"DynamicQuery":[],"GlobalVariable":["4d5df90a-66f1-48b1-9762-7d76c888d153-NjgwMTdiMDhkODY5NzFiMzIzMGY1MzVl"],"ProxyScript":[],"Alternate":[],"ConversationFlow":[],"EntityValue":[],"Entity":[],"Intent":[]},"name":"INAPI","status":"PENDING","version":{"major":0,"minor":0,"patch":1}},"id":"b30f87430eafcaf7db50128a3c815e4f"}
|
||||
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)
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
55
README.md
55
README.md
@ -1,3 +1,54 @@
|
||||
# iva-studio-workspace
|
||||
# IVA Studio Workspace
|
||||
|
||||
Place to put random IVA Studio Workspace files and examples
|
||||
Place to put random files and examples used in IVA Workspaces
|
||||
|
||||
## Channel Automation
|
||||
|
||||
### Interaction Notification API
|
||||
|
||||
Interaction Notification API is used to push Call Pops into Channel Automation.
|
||||
|
||||
#### Prerequisits
|
||||
|
||||
1. Install and configure the *Channel Automation Interface* Package from Resource Center -> Hub.
|
||||
2. Import [Package](./Exports/IVA-Solution-Consultants_Peter's-Workspace_INAPI_e8063074-0129-41df-9a40-2f5386b0b3d5.json)
|
||||
|
||||
#### Source Code
|
||||
|
||||
[INAPI](./Integrations/Global%20Variables/INAPI.js) Global Variable Function
|
||||
|
||||
#### Example Usage
|
||||
|
||||
Conversation Flow Code Block that calls the API with some data and user name 'ccmary'
|
||||
|
||||
```javascript
|
||||
(async () => {
|
||||
const ani = recognizedObject.metadata.ani;
|
||||
const dnis = recognizedObject.metadata.dnis;
|
||||
const firstName = conversationData.customer?.firstName ?? "FirstName";
|
||||
const lastName = conversationData.customer?.lastName ?? "LastName";
|
||||
const studentId = conversationData.customer?.studentId ?? "StudentId";
|
||||
const dob = conversationData.customer?.dob ?? "1/1/1970";
|
||||
INAPI().post(`${ani}`, `${dnis}`, "ccmary", {
|
||||
"@type": "ved:TelephonyCallDataED",
|
||||
"ved:firstName": `${firstName}`,
|
||||
"ved:lastName": `${lastName}`,
|
||||
"ved:studentId": `${studentId}`,
|
||||
"ved:dob": `${dob}`,
|
||||
});
|
||||
})()
|
||||
.catch((error) => {
|
||||
console.log(error.message);
|
||||
recognizedObject.answers.push("");
|
||||
recognizedObject.errorInfo = {
|
||||
...recognizedObject.errorInfo,
|
||||
label: {
|
||||
data: error.toJSON ? error.toJSON() : {},
|
||||
message: error.message,
|
||||
},
|
||||
};
|
||||
})
|
||||
.finally(() => {
|
||||
next();
|
||||
});
|
||||
```
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user