Agenda SDK Dialog: How can a JS SDK app integrate with the phone app
How can a JS SDK app integrate with the phone app to show a widget below/next to the call panel for calls. (yellow area)
Untitled.png


function onPhoneApiUpdate (arg0) {
const provider = arg0.providers[0]
const calls = arg0.model[provider].model.calls;
calls.forEach(function(call) {
console.log("DEBUG " + JSON.stringify(call));
});
}
phoneApi = start.consumeApi("com.innovaphone.phone");
if (phoneApi) {
phoneApi.onupdate.attach(onPhoneApiUpdate);
}
DEBUG {"id":-1,"guid":"90b2234ae7de600174b90090333e234b","dir":"i","num":"202","sip":"atlantis","dn":"Atlantis","state":"Alerting"}
DEBUG {"id":-1,"guid":"90b2234ae7de600174b90090333e234b","dir":"i","num":"202","sip":"atlantis","dn":"Atlantis","state":"Connected"}
DEBUG {"id":-1,"guid":"90b2234ae7de600174b90090333e234b","dir":"i","num":"202","sip":"atlantis","dn":"Atlantis","state":"Holding"}
DEBUG {"id":-1,"guid":"90b2234ae7de600174b90090333e234b","dir":"i","num":"202","sip":"atlantis","dn":"Atlantis","state":"Connected"}
DEBUG {"id":-1,"guid":"90b2234ae7de600174b90090333e234b","dir":"i","num":"202","sip":"atlantis","dn":"Atlantis","state":"Released"}
function onPhoneApiUpdate (arg0) {
const provider = arg0.providers[0]
const calls = arg0.model[provider].model.calls;
calls.forEach(function(call) {
if (call.state == "Alerting" || call.state == "Ringback" || call.state == "Connected") {
phoneApi.send({mt: "CallInfo", id: call.id, html: "<div>This is my call info</div>"});
}
});
}
// test-code
function onPhoneApiUpdate (arg0) {
const provider = arg0.providers[0]
const calls = arg0.model[provider].model.calls;
if (calls) calls.forEach(function(call) {
if (call.state == "Alerting" || call.state == "Ringback" || call.state == "Connected") {
phoneApi.send({mt: "CallInfo", id: call.id, html: "<div style='background:yellow;color:blue;font-size:20px'>This is my big yellow call info</div>"});
}
});
}
const phoneApi = start.consumeApi("com.innovaphone.phone");
if (phoneApi) {
phoneApi.onupdate.attach(onPhoneApiUpdate);
}