Picture of HannesN
Registered 5 years 31 days
HannesN Monday, 15 June 2020, 08:03 AM
I need the pbx Calls info in my app

Dear Innovaphone,


I have the task to create an app that displays the PBX->Calls info in an app (I called the app Call Info). Not everything, but in principle a formatted version constructed from “Number Name Protocol Media Dir Number Name Protocol Media Uptime State“ of all calls as they display in real time in the Admin UI PBX-> Calls. The thing is that this should display in real time with every user of this app, without giving them access to the Devices app, or differently put, without any admin rights.


How I could figure it out is that the call back info from the PBX that I need comes through the innovaphone.pbx.appclient.connection.js file, and specifically the websocket.onmessage msg.data (lines 130-131, see screenshot), however this js file is not in the SDK or app in Visual Studio that I can manipulate or draw from in my development.


To be honest I’m working a bit outside my field and so I’m learning as much as I’m doing, so your help is needed.


What I need to know is:

  1. How can I call this information in my app with code, and without doing something like an iframe where I have to give admin rights to normal users or something?

  2. As far as I can figure it out no ready-made API can give me this, or is there something obvious that I’m missing.


I’m looking forward to your reply.


Regards,


Hannes


Selection_006.png

Picture of HannesN
Registered 5 years 31 days
HannesN Tuesday, 16 June 2020, 09:47 AM
Re: I need the pbx Calls info in my app

Dear Innovaphone,


It seems like consuming the api com.innovaphone.phoneinfo is going to do it, am I right? It will give me the Admin UI PBX-> Calls info of all the calls going through the PBX? If that is the case, then I just don’t know how to receive the messages send by PBX?


The “phoneApi.send({ mt: "CallInfo", id: obj.msg.id, guid: obj.msg.guid, html: "<div>Here's my info</div>" }, obj.consumer);”, in consuming both the com.innovaphone.phone and the api com.innovaphone.phoneinfo api-s, is clear, but what command do I use to get the mt, id guid and consumer? phoneApi.receive.mt, phoneApi.receive.id….?


Thanks for the help,


Picture of HannesN
Registered 5 years 31 days
HannesN Tuesday, 23 June 2020, 02:44 PM
Re: I need the pbx Calls info in my app

Dear Innovaphone,


I have been touching around in the dark, and it is obvious that I had a huge gap in my knowledge of JSON, but I think I have figured it out, however I still need help. As I said I need the Admin UI PBX-> Calls info persistently over all app consumptions without giving admin rights per se.


I had a number of versions of sending call info and catching them with the onmessage function, but I just can’t get it to show over all running consumptions of the app called call_info.


If I create a channel and just send something abetriary, like my name, it shows in all app being consumed, but as soon as I’m consuming Api-s, like phoneApi and phoneinfoAp, then it only shows the info in the respective connection of the two app instances that call each other.


This is the last version touching around in the dark, it is not elegant but I have just been trying everything I can think of, but maybe this is a place from where you can give me some suggestions. I haven’t figured out how the channel should close, but first it needs to work.


var phoneApi = start.consumeApi("com.innovaphone.phone");

var phoneinfoApi = start.provideApi("com.innovaphone.phoneinfo");


// source endpoint

var ch = start.openChannel("call_info", {arg1: 4});

ch.Xonconnected= function() {

phoneApi.onupdate.attach(function (sender, type) {

Object.keys(sender.model).forEach(function (key) {

var provider = sender.model[key];

if (provider.model.calls) {

provider.model.calls.forEach(function (call) {

ch.send({sip: call.sip, guid: call.guid});

})

}

})

});


};

ch.Xonclosed= function() {};

ch.Xonmessage= function(msg) {

if (msg.mt == "EchoResult") ch.close();

};


// destination endpoint

start.Xonopenchannel= function(channel, opener, args) {

var ch = start.acceptChannel(channel);

ch.Xonconnected= function() {};

ch.Xonclosed= function() {};

ch.Xonmessage= function(msg) {

var sipN = msg.sip

var guidN = msg.guid

that.addHTML("sip: " + sipN + " guid: " + guidN)

//ch.send({mt: "EchoResult"});

};

};


Kind regards,


Hannes


2013
Moderator Registered 16 years 72 days
Guntram Diehl (innovaphone) Wednesday, 24 June 2020, 05:00 PM in response to HannesN
1 of 1 users consider this post helpful
Re: I need the pbx Calls info in my app
You could have a look at the RCC Api, if this helps. But with RCC you have to start a UserMonitor for each user.

Or you could do a group dialog subscription with PbxSignal. But you need the group and visibility settings at the users.

Or use HTTP requests doing the same as the PBX calls page, but this requires periodic polling.

Maybe you can describe a little bit more to achive, then we could identify the best way, possibly with a little enhancement of the RCC API?
Picture of HannesN
Registered 5 years 31 days
HannesN Thursday, 25 June 2020, 02:44 PM
Re: I need the pbx Calls info in my app

Dear Guntram,


Thank you for your reply. I’ve done my best to make a quick judgement on the 3 options, and so my preference tends to either option 1 or 2, but not really 3, thus a HTTP request, since I feel it might be an extra overhead that we can avoid.


To make it easy, I’m going to go with the RCC api for now, since it can be a win-win for both of us if I describe our requirements a bit better for archive, as you asked, and when you extend the api. That said, the UserMonitor for each user rather begs my understanding, and so if that can be taken up in the documentation it would be highly appreciated.


The simplest way to put it is that we need the following signals to be communicated from the pbx, to all consumptions of my new app called call_info, without giving admin rights. I called myself in the PBX sandbox on my computer and these are the signals I need in every app as I copied it out of the PBX->Calls in the pbx admin console.


Number: (out)

Name: Test

Protocol: (out)

Media: OPUS-WB (0,0,0)x

Dir: >>

Number: (in)

Name: Hannes

Protocol: (in)

Media: OPUS-WB (0,0,0)x

Uptime: 0d 0h 3m 27s

Status: Connected


If I can copy 1 set of signals out of the documentation that comes the closest is that of the com.innovaphone.phone api under the provider model, which is as follow:


{

registered: true,

calls: [

{

id: 1,

guid: "fff79c5bd2115d0109f400903341035b",

dir: "i",

num: "200",

sip: "charlie.chaplin",

dn: "Sir Charles Spencer Chaplin",

state: "Connected"

}

]

}


I trust this is what you meant to describe it a bit better for archive, and should you do something to extend the RCC api, please let me know ASAP, otherwise I have to pour my energy into option 2. Should that be the case I already have a question or 2, but first things first.


Kind regards,


Hannes


2013
Moderator Registered 16 years 72 days
Guntram Diehl (innovaphone) Thursday, 25 June 2020, 02:55 PM
1 of 1 users consider this post helpful
Re: I need the pbx Calls info in my app
We can have a look at enhancing the the RCC. I will create a presales case for this and take it in development.
Hopefully we have an idea next week.
Picture of HannesN
Registered 5 years 31 days
HannesN Thursday, 25 June 2020, 03:22 PM
Re: I need the pbx Calls info in my app
Dear Guntram,

Thanks so much.

Regards,

Hannes
Picture of HannesN
Registered 5 years 31 days
HannesN Thursday, 25 June 2020, 04:34 PM in response to Guntram Diehl (innovaphone)
Re: I need the pbx Calls info in my app
Dear Guntram,

Sorry my boss asked if any extra costs/licences will come our way with the this RCC api implementation, and eventually the Usermonitor you mentioned?

The licences we have are:
  1. Port13
  2. UC13
  3. SoftwarePhones13
If the RCC api is going to ask for an extra licence, then I have to rather pour my energy in the pbxsignal api and save you the effort to do any pre-sale development.

Regards,

Hannes
2013
Moderator Registered 16 years 72 days
Guntram Diehl (innovaphone) Thursday, 25 June 2020, 04:51 PM
1 of 1 users consider this post helpful
Re: I need the pbx Calls info in my app
The RCC comes with no license smile
2013
Moderator Registered 16 years 72 days
Guntram Diehl (innovaphone) Tuesday, 30 June 2020, 05:42 PM in response to HannesN
1 of 1 users consider this post helpful
Re: I need the pbx Calls info in my app
With the next SR, you will find a new functionality in the RCC Api: The "calls" property you can provide with the "Initialize" message. This turns on the calls information.

Detailed info will be in http://sdk.innovaphone.com/doc/appwebsocket/RCC.htm

Maybe some information is still missing in the calls info, please tell here and we check, what we can do.
Picture of HannesN
Registered 5 years 31 days
HannesN Monday, 6 July 2020, 08:19 AM
Re: I need the pbx Calls info in my app
Good morning Guntram,

Thank you for the Information, and sorry that I'm only coming back to you know, but I was sick the whole last week.

This is great news. When will the next SR be released, so that I can keep my eyes open and do my planning?

Regards,

Hannes
2013
Moderator Registered 16 years 72 days
Guntram Diehl (innovaphone) Monday, 6 July 2020, 09:27 AM
Re: I need the pbx Calls info in my app
The regular patch day is next monday. But there can always a delay if something shows up in the tests.
If you want to start earlier, you could ask support for a development build.
Picture of HannesN
Registered 5 years 31 days
HannesN Monday, 6 July 2020, 10:03 AM
Re: I need the pbx Calls info in my app
Thanks Guntram.

I'm good to wait. Next Monday is not that far away to be impatient and then create more work when something doesn't work as it should.
Picture of HannesN
Registered 5 years 31 days
HannesN Wednesday, 15 July 2020, 08:07 AM in response to Guntram Diehl (innovaphone)
Re: I need the pbx Calls info in my app

Good morning Guntram,


Thanks, it seems like the SR is out with the Calls property.


I don’t know yet if any signals are still missing (thus calls information) and will let you know if it does, however, before that I need some help:

  1. The C++ build is working as it should, after adding of the class and following the tutorial to the T,

  2. However, I did an extensive search in your documentation and I can’t find any indications how to do the JavaScript/JSON implementation, thus how to consume the RCC api, and on top of that the initialising followed by the onmessage, etc.,

  3. I’m convinced it should follow the Innovaphone convention, but by playing around with other Api’s methods of consumption I couldn’t figure out any one to work,

  4. I’m going to be honest, while C++ is my strength, this use of JavaScript/JSON is a maiden voyage for me, and so if I could have a wish I would like a tutorial on this like, e.g., your Client APIs tutorial on JavaScript and JSON, or the phoneInfo API, etc. In different words a short example code of consuming and implementing this RCC Api, etc., would be great.

  5. Maybe I'm missing a Wiki page or something, but I just couldn't get it. If it is there, can you please give me the URL?


Thank you for your great support,


Regards,


Hannes


Picture of HannesN
Registered 5 years 31 days
HannesN Wednesday, 19 August 2020, 02:31 PM in response to Guntram Diehl (innovaphone)
Re: I need the pbx Calls info in my app
Hi Guntram (or anyone at Innovaphone),

Look I know it is obvious for you that I'm coming in from the side, and today I heard that our company can't contact support directly. I have to work over the forum.

My problem is the only RCC Api I have access to is the one in the Tutorial: RCC @ http://sdk.innovaphone.com/doc/tutorials/RCC.htm, but I see no changes in this Tutorial yet.
  1. How do I know or where do I get the latest RCC C++ code and/or Api?
  2. Secondly, the tutorial doesn't really tell me how to consume the api.I know it will be inline with the Innovaphone conventions of consuming api-s, but everything I've tried haven't worked.
  3. Thirdly, I have updated the PBX to the lattes firmware and the app server is up to date, is there anything there I need to take notes concerning the RCC Api?
Thank you guys and girls at Innovaphone.

Hannes
Picture of Carmen Álvarez Méndez (innovaphone)
Moderator Registered 7 years 143 days
Carmen Álvarez Méndez (innovaphone) Thursday, 20 August 2020, 07:02 AM
1 of 1 users consider this post helpful
Re: I need the pbx Calls info in my app
Hi Hannes,

Consuming the API and working with it in Javascript is easier that in C++. Here I give you an example of how to do it, it is not a tutorial, it is just so you could see how the API is consumed and the messages work. Do not forget to give access to the RCC API on your PBX App Object. You can find more information about the RCC JSON messages here: http://sdk.innovaphone.com/doc/appwebsocket/RCC.htm

var innovaphone = innovaphone || {};
innovaphone.RccTutorial= innovaphone.RccTutorial|| function (start, args) {
this.createNode("body");
var that = this;
var rcc = null;

//Consume the Client API to receive the PBX URL
var clientApi = start.consumeApi("com.innovaphone.client");
window.addEventListener("message", onpostmessage);
this.clientAPI = clientApi;

window.addEventListener("message", onpostmessage);

function onpostmessage(e) {
if (e.data) {
var obj = JSON.parse(e.data);
if (obj.mt == "ApiUpdate" && !rcc) {
var url = obj.apis["com.innovaphone.client"]["@client"]["url"];
if (url) {
url = "ws" + url.slice(4, url.search("/APPCLIENT/")) + "/APPS/websocket";
//Set an AppWebsocket connection to the PBX
rcc = new innovaphone.appwebsocket.Connection(url, start.name, null, null, rcc_connected, rcc_message);
}
}
}
}

//This function is called when the AppWebsocket connection is set:
function rcc_connected(d, user, dn, appdomain) {
//The first message that you need to send is UserInitialize with the CN of the user you want to monitorize (in this case the login user)
rcc.send({ mt: "UserInitialize", api: "RCC", cn: rcc.logindata.info.cn });
}

//This function will be called every time a RCC JSON is received
//With every JSON you send, a Result message should be received
function rcc_message(msg) {
if (msg.mt == "UserInitializeResult") {
that.userID = msg.user; //Save the ID
}
else if (msg.mt == "CallInfo") {
if (msg.msg == "del") {
//If a call is disconnected
}
else if (msg.msg.indexOf("-setup") > -1) {
//If a call is set
}
}
else if (msg.mt == "UserConnectResult") {
//Call connected
}
else if (msg.mt == "UserRcResult") {
//Answer to mute/unmute a call
}
else if (msg.mt == "UserParkResult") {
//Answer to park a call
}
else if (msg.mt == "UserPickupResult") {
//Answer to pick up a call
}
else if (msg.mt == "UserHoldResult") {
//Answer to put a call on hold
}
else if (msg.mt == "UserRetrieveResult") {
//Answer to retrieve a call
}
else if (msg.mt == "UserClearResult") {
//Answer to clear a call
}
}

function Call(msg, parent, queue) {
var call = this;
this.id = msg.call;

this.createNode("div", null, null, "callsList").addEvent("click", onSelectCall);
parent.add(call);

this.delete = function () {
call.parent.rem(call);
}
this.connect = function () {
//Send to connect the call
rcc.send({ mt: "UserConnect", api: "RCC", call: call.id });
}
this.connected = function (id) {
//Save the ID of the call
if (id > 0) call.id = id;
}
this.disconnect = function () {
//Send to clear the call
rcc.send({ mt: "UserClear", api: "RCC", call: call.id, cause: 26 });
}
this.mute = function () {
//Send to mute the call
rcc.send({ mt: "UserRc", api: "RCC", call: call.id, rc: 15 });
}
this.unmute = function () {
//Send to unmute the call
rcc.send({ mt: "UserRc", api: "RCC", call: call.id, rc: 14 });
}
this.hold = function () {
//Send to put the call on hold
rcc.send({ mt: "UserHold", api: "RCC", call: call.id });
}
this.retrieve = function () {
//Send to retrieve the call
rcc.send({ mt: "UserRetrieve", api: "RCC", call: call.id });
}
this.park = function () {
//Send to park the call
rcc.send({ mt: "UserPark", api: "RCC", call: call.id, position: -1 });
}
this.unpark = function () {
//Send to pick up the call
rcc.send({ mt: "UserPickup", api: "RCC", call: call.id, user: that.initID });
}
}
Call.prototype = innovaphone.ui1.nodePrototype;

}
innovaphone.RccTutorial.prototype = innovaphone.ui1.nodePrototype;

Regards,
Carmen
Picture of HannesN
Registered 5 years 31 days
HannesN Thursday, 20 August 2020, 09:29 AM
Re: I need the pbx Calls info in my app
Thanks so much Carmen
Picture of HannesN
Registered 5 years 31 days
HannesN Monday, 24 August 2020, 07:40 AM in response to Carmen Álvarez Méndez (innovaphone)
Re: I need the pbx Calls info in my app
Morning Carmen,

Your example really helped me thanks, however I still need at least 2 things:

  1. I need the latest RCC api itself. I built the RCC api from the tutorial @http://sdk.innovaphone.com/doc/tutorials/RCC.htm, but I'm not sure that is the latest version, or does that make no difference. I have upgraded both the pbx and the app platform.
  2. Secondly I need to make sure I use the signals that we need, thus every app instance that display all call activities of all calls going through the pbx. I need to know we have what Guntram said, nl. "With the next SR, you will find a new functionality in the RCC Api: The "calls" property you can provide with the "Initialize" message. This turns on the calls information."
Regards,

Hannes
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 179 days
Daniel Deterding (innovaphone) Tuesday, 25 August 2020, 11:02 AM
1 of 1 users consider this post helpful
Re: I need the pbx Calls info in my app
Hi Hannes,

1. if you updated your PBX to 13r1 SR16, you should be automatically talking with the latest RCC API. There were no changes on the App side, just on the PBX side.

2. at some point you send the Initialize message and here you have to set calls to true. Instead of sending a UserInitialize, can you send this:

rcc.send({"mt":"Initialize","api":"RCC","calls":true});

You should then get some UserInfo messages and finally an InitializeResult.
If you then do some calls, you should see the new CallAdd, CallUpdate and CallDelete messages?

Greetings,
Daniel

Picture of HannesN
Registered 5 years 31 days
HannesN Tuesday, 25 August 2020, 11:24 AM
Re: I need the pbx Calls info in my app
Thanks Daniel
Picture of HannesN
Registered 5 years 31 days
HannesN Wednesday, 2 September 2020, 08:12 AM
Re: I need the pbx Calls info in my app

Morning Guntram, Carmen and/or Daniel,


Our app is doing what it should do and is almost finished, but 2 signals from PBX calls are not coming through. Guntram you said should that be the case I should let you know. So the two signals that I can’t find are:


  1. The Media,

  2. And the protocol


If they are indeed coming through in the msg signal, please help me to find it.


Thanks in advance


Kind regards,


Hannes


← You can define your color theme preference here