Replacing Action URL & URI in SIP phones or managing via websockets?

SIP phones. Computers with a handset. In theory, a lot can be done with them, but they are used only for calls :-)



Recently AsterConf was at the conference, and there the vendors talked about their phones, we will not single out anyone, they are all good, somewhere better, somewhere cheaper, in fact they do the same thing.



Some of the vendors improve the sound quality, someone fastens a tablet with an android, someone tries to add some kind of application. And all so that we install these phones on desktops.



And maybe phones are good candidates for the role of the console in the IoT world: I clicked on a button and got a result. And, in my humble opinion, there is not enough simple way to connect phones to your “Manager”. As part of this article, I want to show how it might look simple in a diagram and video demonstration.



And you share in the comments, please, that maybe something similar has already been implemented somewhere or supplement your suggestions and thoughts.



Phones have Action URL and Action URIs.



Action URL allows us to send different events to any url. In the url, we can specify predefined variables that will be filled with real data during a call.



So, for example, looks like setting up my phone.







Action URL Designer Online for Yealink



The Action URI allows us to receive commands to the IP address of the phone, and the phone can make calls, answer calls at the command, add volume, reboot, etc. in the video below you can see how this all happens. We must indicate the address from which the teams will come.







Everything is configurable, what's the problem, bro?



These are quite functional interfaces, but ... they are quite difficult to integrate. Those. we need to take 100,500 actions to make it work. Or fill in 100 fields in the settings of the device (you see on the screen yourself), or get confused with provisions and prescribe some configuration templates.



As a result, there are a lot of actions in which it is easy to make a mistake and not get what you want, and then spend a lot of time to figure out the reasons for the inappropriate behavior of the device. And well, if you cope with one, and you have five to ten, one hundred, and a couple of vendors and even models of different generations. Pooh pooh ...



Is this a problem? Does anyone need to manage a subscriber’s phone? To the subscriber? From your desktop, laptop or smartphone? Technical support? Both internal and external, for example, a virtual telephone exchange provider? Do I need to have access to the phone differently than just SIP? Integrate the phone with applications, bypassing the IP-PBX?



I can’t answer unequivocally, there are cons and pros. And to realize the advantages, I would like to be able to quickly connect the Action URL and Action URI to my "Manager". I call a manager a server from which I can centrally see a list of phones, their status, and from any of them perform some available action.



Let's see the diagram.







Imagine that we have a websockets client in our phone.



Then we need to specify in the phone only the network address of the “Manager” and our phone will connect to it. When connected, the phone will send its id, name, mac. This will allow us to compare it with our list of PBX subscribers, for example.



Then we subscribe to events that occur on the phone. There are a lot of them, these are re-registrations, answers to calls, button presses, etc. Then we can dial the number from our Manager by sending a command. Either set DND, or remove DND. Then I send a notification or reminder to the phone, set a new logo.



What about security? In general, SIP phones can work for NAT, they do not need an external address. But if you set the phone’s web server port to the Action URI network (where the admin area, by the way, works) - expect unpleasant surprises.



But if the phone will connect to the “Manager” via websockets, then this is his initiative and his right, it may disconnect, and if you connect to the remote server due to NAT, it will look like a browser connection.



Enough of the words, closer to the point. I wrote a small phone client (which in my opinion should be in the phone), which connects to the server via the web socket. Also, a browser is connected to this server, which can receive messages from the phone and send commands there.



The client is just a wrapper for the Action URL and Action URI, which works with the phone through its familiar interfaces, and wraps all the data in a web socket. In web sockets we have regular JSON messages that any web developer can work with.



Watch the video, everything is quite simple. All code is minimal enough just to show the concept.





What is going on in the video?



  1. we start the server which accepts connections on websockets,
  2. we launch the client (which works by Action URL & URI with the phone)
  3. client connects to server
  4. we start the web server (with the page where the code for connecting from the browser via websockets)
  5. open the page in the browser, the page connects to the server
  6. we are sending a request for information from the page
  7. the request goes all the way to the phone and returns information about the phone lines
  8. also we can send different teams
  9. including the command to make a call
  10. and then the hang up command
  11. all data is visible in the log on the page, as well as in the console of the working server and phone client
  12. then you can see how it reacts to commands from the phone page


Thus, connecting the phone to the Manager is enough just an address. And messages from web sockets to a different presentation and vice versa can be any developer. In my case, just a page is connected to the Manager. In general, it can be a more complex system that will process commands and send messages to the phone.



Having a simple connection method can be convenient, and therefore easier to learn. Through this interface, in theory, you can send both new configurations and additional messages, making the phone easily integrated into any infrastructure.



In general, these are just my thoughts on the results of viewing new products at Asterkonf. I will be glad to see in the comments the pros and cons. And maybe one of the manufacturers will see the rational in this and introduce the chip :-)



Github Project



All Articles