
Making Miranda make calls is easy using SIP telephony plugins that turn Miranda into a softphone,
However, what to do when users do not have any headsets or microphones?
But to educate users to work with the soft-background, built-in with Miranda - a bad dream.
Option one is to use existing telephones (IP, analog, digit) to make calls from Miranda.
Initial data:
1. Digital mini PBX Panasonic TDE200, to which all phones are connected
2. A bunch of subscribers with different types of phones: IP, analog, digital, system phones
3. A working XMPP server based on OpenFire
4. Miranda client for communication via XMPP (Jabber) protocol - installed for all users.
')
Wishlist:
1. The ability to make a call using the client Miranda.
2. The call and conversation should be made by usual working phones (IP, analog, digit).
3. Phone number information must be taken from Active Directory.
4. Transparency / ease of use for users.
5. When making a call, add an alert on Jabber about the caller.
Anyone interested in the introduction - welcome under cat. Below it will be interesting.
Prehistory
A few years ago, in search of a solution for corporate IM-service on the Internet, I came across an
article by IT specialists from the city of Kirov, about corporate IM-Service on OpenFire with transparent user authentication, where Miranda acted as a client, and not possible to initialize Connecting via RDP and VNC to the computer whose user you selected in the contact list, you do not need to enter the DNS name of the user's computer, it is automatically inserted into the address field, and establishes a connection.
I used their Miranda build for quite a while, but over time, glitches began to appear in the work, connection instability, and client departures.
As a result, it was decided to assemble my Miranda
with blackjack and ... with a new core and necessary functions.
New client
Assembling your own Miranda assembly is not a tricky business: I installed the latest version of the kernel, I saved up the necessary plug-ins, and voila - its own assembly.
But the article is not about that.
The new client Miranda completely duplicated the functionality of connecting to RDP and VNC, however it became much more stable due to the updated kernel (I will call it “admin client”). By the way - for users their own Miranda was assembled, but already without the connection “buns” (user client).
For several months, the client worked successfully with our technical support team - there were no complaints.
During this time, I successfully implemented monitoring for Active Diretory (article
here and
here ), behind the file server (
here ) and VPN servers.
In the process of creating a monitoring, I heard several times from the technical support guys that it would not have been bad to add the ability to connect to the user using the Remote Assistance, since we have it is the de facto standard for user support
Actually, it did not cause any difficulties.
It would seem - what else is needed? Everything you need to support is present.
Small retreat
At that moment, I became interested in C # programming - rewrote all monitoring with Powershell in C #, screwed monitoring to the database (I used to write to text files) and made a simple web page with php that pulled monitoring data from the database - it became very good .
On the page it was possible to make a sample:
1. for AD changes: by username or computer name
2. for file server: by username or file name
3. for VPN servers: by username
Updated new customer

For even greater convenience of technical support for users, it was decided to add a sample of the required user to the Miranda client.
How it works:
To connect to the example via RDP, Miranda using a specific plug-in can return not only the value of the user's computer name, but also the user’s login.
The client added the functions of opening web pages with monitoring tables, to the URL of which the login of the required user was transferred by GET.
As a result, the client has acquired a completely different color - now he not only allows real-time support, but also performs analysis on past events concerning a given user (for example, this way you can find out which files this user opened or deleted on a network resource what servers did he try to connect to, what actions were performed with his account in AD).
Next, I wrote a simple WindowsForm application in C #, which, using a WMI provider, can receive a list of processes of a remote computer, with the possibility of their completion.
Without hesitation, this application was "embedded" in the functionality of the admin client.
Now, user support has received a new coloring: there is no need to keep tables with data about computers, IP addresses, users who work on these computers, and even more now there is no need to request information about the computer’s name or IP address from the user (assuming of course he still has the network, otherwise Miranda will not be able to “take” the name of the computer of the user who is offline, but the user's login will be able to).
It was a prehistory, now the main theme is the ability to make calls
As the saying goes: Laziness is the engine of progress.
This client minimized manual data entry to connect to the user or search for information about him in the monitoring database — everything is done with 2 clicks.
In the process of using Miranda with advanced functionality for 2 years, I occasionally visited the idea that it would be nice to make the ability to make calls using the Miranda client - without having to dial numbers manually.
One problem is that we do not have IP telephony, or rather, it is there, but it is used by 5% of subscribers :)
Those. I want to make it so that when you select a user in the Miranda contact list, you can choose an action - “call”, and talk on your usual work phone.
Then one day he set himself the task - to realize it. No sooner said than done!
Given:
1. Panasonic PBX TDE200
2. 300 subscribers (15 - SIP, 285 - analog or digital phones)
3. Miranda (where do without it)
4. A drilling idea that keeps you awake at night :)
Let's go from the reverse, i.e. from telephones to Miranda.
We connect Panasonic to LAN
The first thing I wondered how Miranda will reach the PBX.
The solution turned out to be straightforward - Asterisk.
I will not touch upon the procedure of installing and configuring Asterisk, there are already many articles on this topic on the network.
We combine Asterisk and Panasonic TDE200 with a SIP trunk, according to this
article .
Made by Now using a computer, you can make calls to users' phones. However, we need to make calls from ordinary phones, without dialing. We dig further.
Callback
Asterisk is a powerful software IP PBX, everything you can think of with telephony - Asterisk can do.
Including it has a great feature like CallBack, i.e. callback - from this and we will dance.
Asterisk can also form a call automatically using specially crafted call files (call-files). They contain information about the phone numbers to which you need to make a call. These files when placed in a special folder on Asterisk and initiate a call to both subscribers and connects them.
Sample file text:
Channel: SIP/utde/9311264 CallerID: test <9311264> Context: from-internal Extension: 994120031
This means that the asterisk should call the numbers: 9311264 (our number) and 994120031 (where we call). The call to both numbers leaves from the number 9311264 (ie, from ours, specified in the CallerID property).
Automating the creation of call files
To automate, we will use the usual bash-script, which, using the
echo command, will write the necessary data to the new call-file for making a call: i.e. phone numbers of the caller and the caller. We will transmit both phone numbers with parameters when running a bash script, for example:
call.sh 945954 945932Sample script for generating a Call file:
How to run a bash script "from the outside"
All this is wonderful, we can, by running the script and passing it 2 parameters, make the call to the phones of two employees and combine them into a conversation.
But how do we get to do this without being in the console on the server where Asterisk is located?
The answer is quite simple - web.
Let's deploy apache, create a php page that will run the bash script and send it 2 phone numbers as parameters.
It is possible to start bash_script from php with the following function:
shell_exec("sudo /var/scripts/out.sh $from $to");
Where the script name is: out.sh
Your phone number in the parameter: $ from
Number to call: $ to
We transfer data to php
Like the bash script, the php page should get 2 phone numbers. The easiest solution to this problem is the GET method.
Those. A specially crafted URL, carrying 2 phone numbers, sends them to php, where they are already transmitted to bash.
Using the GET method to transfer to a variable is not difficult, it is enough to specify in php-code:
$from=$_GET['from']; $to=$_GET['to'];
Those. the $ from and $ to variables are assigned the values ​​that were passed to the url in the from and to parameters,
For example the link:
pbx.domain.ru/index.php?from=943216&to=987632sends the $ from number to the $ from variable telephone number 943216, and to the $ to variable - 987632
We form a GET request from Miranda
To solve this problem, I did not find a ready-made solution, so it was decided to write the application itself, which would itself form the necessary URL and make a request for it, passing phone numbers. And of course, implemented it in C #. Let's call this application conditionally:
Application C # .
What the application does:
1. Accepts from Miranda the input parameter is the login of the employee to whom we want to make a call.
2. Picks up the current username on our computer (i.e., our username)
3. Makes a request to Active Directory, in which it searches for these users by their usernames and returns their phone numbers (Phones must be specified in the telephoneNumber account attribute).
4. Generates a URL into which it inserts 4 values: the number of “who is calling”, the number of “who is calling”, the login “who is calling”, the login “who is calling” (For example:
pbx.domain.ru/index.php?from=924374&to = 859345 & fromLogin = ivanov & toLogon = petrov (I give the logins to create an alert, about this below).
5. Makes a request to this URL.
At this "caller" is ready.
This is what the context menu of admin Miranda looks like now:

And so the users:

When the “Call” function is selected, the C # Application starts:

The user selects which number wants to make a call, and presses the appropriate call button.
If the mobile number is not listed in Active Directory, then it will not be displayed (as well as the call button).
If this user does not have numbers, the application will report this.
Create an incoming call alert
Since for most users, the phones do not have a contact list, then it is difficult to determine who is calling, even if you see which number is calling you, the alert function has been added to Jabber about who is calling: full name, position, department, phone number.
Above, I wrote that the application transmits in addition to 2 phones also two logins.
Those. php can accept 4 parameters, not only phone numbers but also logins.
We add php. Add the query function in Active Directory.
What php does in the end:
1. having received logins, makes a request to AD to receive a full name, position, department of a person who makes a call
$srv = "10.10.10.1";
2. generates a message containing information about the caller.
3. Runs a bash script to which it sends the message body and the login to "who's being called."
The bash script launches the sendxmpp (Perl script to send messages via the XMPP / Jabber protocol, is freely available in the repositories) and sends it the message body and the login name. Sendxmpp sends a message to the user from a specially created contact (let's call it
Operator ).
Also in the body of the message is transmitted a link, upon opening of which, a callback is created, to the person who called you - made for convenience. For example, you missed the call, saw the message, although the message contains information about the caller’s number, but “Laziness is the engine of progress” and we don’t want to manually dial the number on the phone, or search for this employee in the Miranda contact list to make the call - We just click on the link, and all this cotovasia with skipty starts to work:
there are requests to AD from php
a message is formed to the person that you are calling to him, also with reference to the chime
call-file is formed
phones are ringing
So the message looks like:

Conclusion
As a result, we received a full-fledged client, from which you can connect to users, view monitoring information, make calls with one click.
The advantage of this solution is that all data is taken from Active Directory, which makes it easy to store data about phone numbers - you only need to store it in one place.
The C # application requests data in Active Directory not only about the work phone number, but also about the mobile. And we can choose which number we want to call: work or mobile.
Calls are also made to long-distance numbers, this is especially true for us, because we have several branches in different cities - which undoubtedly simplifies life, because no need to dial long phone numbers with city codes.
General scheme of work:

It looks of course cumbersome, but in practice, after pressing the "call" button, your phone starts ringing after 1-2 seconds.
Security
All this works fine, but there are nuances in security:
1. I encode phone numbers and logins in a C # application so that they are not transmitted in clear text (since the link is present in the alert text). Php already decodes them and receives normal data (numbers and logins).
2. Be sure to read online about Asterisk protection. At a minimum, configure iptables and allow only your subnet to go to Asterisk.
Question: Tell me, how can I realize a timeout, for example, so that the user cannot make a call through Miranda, within 30 seconds after the start of the previous call? It only comes to mind to record IP addresses and the time when the call request came from. MB are there any other options?
PS: Since Entering phone numbers in Active Directory is quite a tedious task, I wrote a small WindowsForm application in C # that runs once on users' computers and asks them to indicate their phone numbers (work and mobile). This data is written to the corresponding attribute of the user account in Active Directory. This application can not close the feed as you enter your data. You can close through the task manager, but users usually do not reach it.
This application was also added to the Miranda client so that users can always enter their phone numbers if they have changed. (Here, of course, you can close the application without having to write down your number).
PSS: Thank you for helping with
Asched Lanched