Get call list

Hello,

I’ve looked around the API documentation but couldn’t find what I needed.
Through the Javascript API I want to be able to get notified when an extension is ringing and get the number who is calling. Also, I’d like to be able to get a list of missed calls for my extension.

I know that keevio does all of this, ideally I’d like to do this without needing to implement the full keevio.
Could you please point me in the right direction?

Thanks,
Anthony

Does this link help at all? https://developer.ipcortex.co.uk/samp/call-manage/

Unfortunately the both API doesn’t keep a list of calls server-side of calls you have missed before you’ve loaded it. (The same is true of keevio, which uses the API underneath - and uses local storage to keep a list of calls it has seen.)

Hi Jamie,

Thanks for your help. I think the link you’ve attached might help.

IPCortex.PBX.owned[0] returns nothing for me. I’m pretty sure everything is correctly set up for the account I’m logged in as.

Any suggestions?

Anthony

Hi Anthony,

Does the summary screen on the PABX show the user as owning a phone? (Or having keevio phone.) They will have a little green person symbol next to them if these do:

Best regards,
Jamie

Hi Jamie,

Yes it does please see screenshot below.

Anthony

Hi Anthony,

Sorry I forgot to mention - you also need to own the extension as well for the device to appear in that list.

Best regards,
Jamie

Apologies - I misinformed Jamie, Just owning the phone should be sufficient to see the currently logged-in user’s owned device list.

Perhaps you are logging in as the wrong user? For example, logging in as ‘admin’ will always give you an empty owner array as the admin user cannot own a phone. Be careful of using the same browser to log in twice too - The sessions can get mixed up and you may not be logged in as you think you are. If this is the case, try using Incognito mode in the browser.

Does that help?
Cheers,
Steve

Hi Steve,

Thanks for your help.
I just tried the following: I opened a new window in a different browser, logged in as the correct user:

IPCortex.PBX.Auth.setHost("https://10.11.11.90"); IPCortex.PBX.Auth.login(function (res) { console.log(res); }, { username: "user2", password: "password" } ); IPCortex.PBX.owned[0];

And the same thing happened see below:

The configuration is correct as I’ve been told by our support tech guys.

Is it possible that is because of the API version? I’m using API version 1.9.1. Or maybe because the users are configured to have softphones (x-lite) and not physical phones?

Thanks,
Anthony

Anthony,

I would be curious as to the contents of:

IPCortex.PBX.phones

and of

IPCortex.PBX.Auth.uname

I do not believe it will be the API version, or that it is X-Lite. What is the PABX version?

Regards,
Steve

Hi Anthony,

I think I can see the problem as you have posted your tiny code snippet verbatim (sorry Steve, just came to me).

You aren’t waiting for login to resolve (via a callback in your code) before you try to resolve the owned[] array. I think you may also need to call startFeed() if you later want live data so I would use something more like:

IPCortex.PBX.Auth.setHost("https://10.11.11.90");
IPCortex.PBX.Auth.login(function (res) {
  console.log(res);

  /* Get the API to start collecting data */
  IPCortex.PBX.startFeed().then(
      function(s) {
            console.log('feed started', s);
            console.log(IPCortex.PBX.owned[0]);
             /* REST OF YOUR CODE CALLED FROM HERE */
           },
           function(f) {
              console.log('Live data feed failed',f);
            }
        );
    },
   {
    username: "user2",
    password: "password"
  }
);

Hello,

Thank you both for your help.

Rob, the solution you posted was exactly right!
If I have any troubles in the next steps of the process I will let you know.
Thanks again for the help!

Anthony

Hello again,

I’ve been using the code that rob posted successfully for the past few months, until the API got updated to version 2.0.1 last week and since then the click2dial does not work:

IPCortex.PBX.Auth.setHost(pbx_url); IPCortex.PBX.Auth.login(function (res) { if (res){ /* Get the API to start collecting data */ IPCortex.PBX.startFeed().then( function (s) { console.log('feed started', s); var owned = IPCortex.PBX.owned; var myPhone = owned[0]; // myPhone.enableRTC(); console.log(myPhone); window.myPhone = myPhone; window.owned = owned; pbx_functions.listen(); }, function (f) { console.log('Live data feed failed'); console.log(f); } ); } else { alert('Unable to log you in to the phone system. Please make sure your username and password are correct.') } }, { username: pbx_username, password: pbx_password } );

If I use the command myPhone.enableRTC(); I get the following error: Error: JsSIP not loaded.

Regardless of that, I manage to successfully log in to the API, but I can’t dial a number through the API.
When I use the dial function ( myPhone.dial(‘01914820444’); ) I get the following error:
Uncaught (in promise) Error: 5s Timeout setting up call at api.js:3952

I can see in the browser that the post to the api.whtm is successful, but then a few seconds later we get the above error.

Is there anything you can suggest? This is very urgent as it is being used in production and it is not working for our clients!

Thanks,
Anthony

Hi Anthony,
Could you give us a bit more context with the full source code and what you are trying to do and browser version etc. Is the intention to use the API to dial a number on the users owned (hardware) phone, or to dial using WebRTC directly within your client? Where exactly in your source code, and on what object are you calling dial()?

Hi Rob,

As I said before the code was working fine until the API was updated to version 2, so I’m assuming it has something to do with that.

Browsers: both Chrome and Firefox have the same issue (latest versions).
This is the code, I’ve put this in a function and I call it when the page loads.

        IPCortex.PBX.Auth.setHost(pbx_url);
        IPCortex.PBX.Auth.login(function (res) {
                if (res){
                    /* Get the API to start collecting data */
                    IPCortex.PBX.startFeed().then(
                        function (s) {
                            console.log("feed started", s);
                            var owned = IPCortex.PBX.owned;
                            var myPhone = owned[0];
                            // myPhone.enableRTC();
                            console.log(myPhone);
                            window.myPhone = myPhone;
                            window.owned = owned;
                            pbx_functions.listen();
                        },
                        function (f) {
                            console.log("Live data feed failed");
                            console.log(f);
                        }
                    );
                } else {
                    alert("Unable to log you in to the phone system. Please make sure your username and password are correct.")
                }
            },
            {
                username: pbx_username,
                password: pbx_password
            }
        );

As you can see, after the user is logged in and after startFeed, I set var myPhone = owned[0];
And I call myPhone.dial(number); when the user clicks on a telephone number in the application.

The intention is to use the API to dial a number on the user’s physical phone.

API version 2.0.1, IPCortex PBX firmware version 6.2.0.161105.

Anthony

Calling myPhone.enableRTC() would definitely be the wrong thing to do as that enables the internal WebRTC phone functionality within the library which will either fail (if you aren’t including the right headers), or mess up any copy of keevio you are running locally and in any case not work if you don’t put the right handlers in to connect audio up to a media stream.

Assuming that owned[0] is a hardware handset that is registered with the PBX and working, and it and the rest of the API are in scope at the point where you are calling owned[0].dial(number) then it should work. I have lots of code that works OK like this in 6.2 and it is backwards compatible. The timeout would imply that the dial is failing for a reason that may be specific to that handset/user which could conceivably be something that is unrelated to the upgrade.

Hi Rob,

I had the line myPhone.enableRTC() commented out. The only reason it was there was because it was on one of your examples in the documentation.

To honest I think the timeout issue has been resolved now, as I just carried out a test on my machine. I’ll confirm with the client tomorrow and I’ll get back to you.

Anthony

Hello again,

Thanks for all your help. The issue has now been resolved, apparently there was a bug in the Asterisk Manager Proxy.

Anthony