I need to display callers input in front end app. additionally need to store that input in call history for reporting purposes categorization of call purposes.
As I could not find way to directly get caller keypad input frontend app, I have setup routing automation flow with single input options and set a action function and used SMI method to pass caller keypad input to Front end app but data pass without caller input ( it is missing on response object)
Server.js
exports = {
serverMethod: function(req) {
userInput=req.input
response = 'valid';
// Third party API and response structure
renderData(null, { success: true, data: {
"req": req,
response,
"app_variables": {"userInput": req.input,'Hello':'World'}
}});
},
app.js
let client = null;
$(document).ready(function () {
app.initialized()
.then(function (_client) {
client = _client;
client.events.on('app.activated',
function () {
let options = { "name": "hello world" };
client.request.invoke("serverMethod", options).then(
function (data) {
// data is a json object with requestID and response.
// The serverless environment generates the request ID.
/*The serverless method in server.js returns two objects (error,response).
data.response is the response object from the serverless method.*/
console.log("Server method Request ID is: " + data.requestID);
console.log(data.response);
},
function (err) {
/* err is a json object with requestID, status, and message.*/
// The serverless environment generates the request ID.
/* The serverless method in server.js returns two objects (error,response).*/
/* The error object contains the status and message attributes.*/
// err.status is the error.status attribute.
// err.message is the error.message attribute.
console.log("Request ID: " + err.requestID);
console.log("error status: " + err.status);
console.log("error message: " + err.message);
});
//
client.data.get("currentCall").then(
function (data) {
// success output
getUserData(data.caller.from)
},
function (error) {
console.log('1---------------------------------error')
console.log(error)
}
);
});
});
});
manifest.json
{
"platform-version": "2.3",
"product": {
"freshcaller": {
"location": {
"notification_card": {
"url": "template.html",
"icon": "icon.svg"
},
"conversation_card": {
"url": "template2.html",
"icon": "icon.svg"
}
},
"events": {
},
"functions": {
"serverMethod": {"timeout": 20},
"userInputMethod": {"timeout": 20}
},
"requests": {
"getUserDataReq":{}
}
}
},
"engines": {
"node": "18.13.0",
"fdk": "9.3.0"
}
}