Picture of marcorcau
Registered 5 years 321 days
marcorcau Thursday, 9 September 2021, 05:43 PM
Agenda SDK Dialog: Using PbxAdminApi from an app and not a PBX Manager plugin
Hello,

In our app, I have successfully modified the default PBX Manager plugin to add fields to it an update the app object accordingly. Specifically, as you can see in the attachments, the "Icon URL" field.

It would be very useful for us being able to modify the app object not from the PBX Manager plugin but from the App itself. Is this possible at all?

We tried to use the PbxAdminApi in the same way as the PBX Manager plugin does, from the Javascript client code, and we also tried to call this API directly from the service object but none of our attemps worked.

We never obtain a response from our GetAppObjects or similar calls. Is this API available to apps or only to PBX Manager plugins?

Our perfect scenario would be not only being able to update this "Icon URL" field but also create / edit / delete full app objects.

Regards,
Marc ///
Screenshot_20210909_172511.png

2013
Moderator Registered 16 years 15 days
Guntram Diehl (innovaphone) Friday, 10 September 2021, 08:59 AM
Re: Agenda SDK Dialog: Using PbxAdminApi from an app and not a PBX Manager plugin
Did you check "Admin" in the App Objekt to allow the App Service the use of the Admin API?
Picture of marcorcau
Registered 5 years 321 days
marcorcau Tuesday, 8 February 2022, 02:40 PM
Using PbxAdminApi from an app and not a PBX Manager plugin
Hello,

I am again trying to interact with PbxAdminApi in similar ways as the PBX Manager plugin does, but from a normal App, trying to create, update App Objects.

This time I have checked "Admin" and "Websocket" permissions in the App Object, and copied parts of the plugin code at
[company].[appname]manager.js
into my App, but still get no response from the PbxAdminApi.

This is the basic code of my app:

 var managerApi = start.consumeApi("com.innovaphone.manager");

 var app = new innovaphone.appwebsocket.Connection(start.url, start.name);
 app.checkBuild = true;
 app.Xonconnected= app_connected;
 app.Xonmessage= app_message;

 var src = new managerApi.Src(pbx);

 function app_connected(domain, user, dn, appdomain) {
 src.send({ mt: "GetAppObjects", api: "PbxAdminApi" });
 }

 function app_message(obj) {
 }

 function pbx(msg) {
 console.log("Got PBX message");
 console.log(msg);
 } 

I have been able to use and get messages from other APIs (com.innovaphone.client, com.innovaphone.search, com.innovaphone.phone) but I am unable to get any response from this PbxAdminApi.

Is there any obvious error in the code above making it fail?

Do I need to add a instanceLogin in the innovaphone.appwebsocket.Connection method as PBX plugins do?

Thanks a lot.
Marc ///

Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Monday, 14 February 2022, 01:54 PM
Re: Using PbxAdminApi from an app and not a PBX Manager plugin
Hello Marc,

just to clarify here - the following object represents a WebSock connection to the App Service, not to the PBX:

var app = new innovaphone.appwebsocket.Connection(start.url, start.name);

In order to open a new WebSocket connection to the PBX, you have to create a new object for this purpose, using corresponding URL and credentials.

Better solution would be to do this from App Service, not from client , where you have already a working WebSocket connection from the PBX.

Best Regrds
Andreas Fink
2013
Moderator Registered 16 years 15 days
Guntram Diehl (innovaphone) Friday, 25 February 2022, 09:51 AM in response to marcorcau
Re: Using PbxAdminApi from an app and not a PBX Manager plugin
This is a security issue. You do not want to give a user full access to the PBX (with the AdminApi you basically do this), only because you give access to an App, which needs the AdminApi.

This is why it is better to do this thru the App Service.
← You can define your color theme preference here