From a2ce64013255cbff3573ea695946d9e59649b011 Mon Sep 17 00:00:00 2001 From: "Peter.Morton" Date: Fri, 25 Apr 2025 15:32:25 -0500 Subject: [PATCH] Adding basic_messenger for PoCs with other Speech Services --- README.md | 139 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 111 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 9102515..e9af07f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ 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. +1. Install and configure the _Channel Automation Interface_ Package from Resource Center -> Hub. 2. Download then Import [INAPI Package](./Exports/IVA-Solution-Consultants_Peter's-Workspace_INAPI_e8063074-0129-41df-9a40-2f5386b0b3d5.json) #### Source Code @@ -23,32 +23,115 @@ Conversation Flow Code Block that calls the API with some data and user name 'cc ```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}`, - }); + 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(); - }); + .catch((error) => { + console.log(error.message); + recognizedObject.answers.push(""); + recognizedObject.errorInfo = { + ...recognizedObject.errorInfo, + label: { + data: error.toJSON ? error.toJSON() : {}, + message: error.message, + }, + }; + }) + .finally(() => { + next(); + }); +``` + +## Basic Messenger + +Built for PoCs with other Speech Services, this provides a simple text from a prompt interface for IVA Studio + +### Prerequisits + +1. Install and configure the _Core Messenger Webhook_ Package from the Resource Center -> Hub. + +### Source Code + +[basic_messenger](./Integrations/Proxy%20Scripts/basic_messenger.js) Proxy Script + +### Example usage + +```sh +curl --location 'https://router.ivastudio.verint.live/ProxyScript/run/67bca862210071627d32ef12/current/basic_messenger' \ +--header 'Content-Type: application/json' \ +--data '{ + "input" : "What is the weather", + "model" : "main" +}' +``` + +```json +{ + "id": "resp_c8191807-c478-41d0-a73c-68d361eae5a3", + "object": "response", + "created_at": 1745609535, + "status": "completed", + "model": "main", + "output": [ + { + "type": "message", + "id": "msg_56594e02-ae08-47ce-8c7f-d5165b1fa9de", + "role": "assistant", + "content": [ + { + "type": "output_text", + "text": "Could you please provide a city or a zip code to get the weather information?", + "annotations": [] + } + ] + } + ] +} +``` + +Note the use of "previous_response_id" to manage conversation state. + +```sh +curl --location 'https://router.ivastudio.verint.live/ProxyScript/run/67bca862210071627d32ef12/current/basic_messenger' \ +--header 'Content-Type: application/json' \ +--data '{ + "input" : "Chicago", + "model" : "main", + "previous_response_id" : "resp_c8191807-c478-41d0-a73c-68d361eae5a3" +}' +``` + +```json +{ + "id": "resp_c8191807-c478-41d0-a73c-68d361eae5a3", + "object": "response", + "created_at": 1745609627, + "status": "completed", + "model": "main", + "output": [ + { + "type": "message", + "id": "msg_ef591b4c-b08b-49fe-85a5-306c94269bf6", + "role": "assistant", + "content": [ + { + "type": "output_text", + "text": "Can you provide the zip code for Chicago?", + "annotations": [] + } + ] + } + ] +} ```