If anyone is interested in helping create a new site logo please email webmaster@allworxforums.com

PLEASE NOTE: Allworxforums.com is not owned, nor run by Allworx Corp. The views and opinions found on this forum are not necessarily the views of Allworx or the forum moderators. Neither Allworx nor the forum will be held liable for any information found on the forum. The Allworx logo and name is a registered trademark of Allworx Corp.

Generate an email when a phone is called

Support for Allworx Call Assistant, Mobile Link, and TAPI.
doom1701
Posts: 69
Joined: Tue Sep 20, 2011 6:52 pm

Generate an email when a phone is called

Post by doom1701 »

Putting this into Software Support since it'll probably come back to being a TAPI thing. We have an extension for our helpdesk. When a user calls this extension, in addition to ringing all of our helpdesk phones, I'd like to have the system generate an email to our ticketing system so that a helpdesk ticket gets created.

I played a little with Follow Me; since you can't follow to an internal extension, I had to follow to a DID and setup a voicemail account with a blank outgoing message. As long as the follow timeout was longer than the message, a voicemail would get created and open a ticket. This was kind of a cludge, though--we had to call an external number, so it's using SIP trunk resources, and since the VM came in from a DID as well, the email would be generated from a generic user ID. I really want to find a way to have the email/voicemail come from the caller, so it gets tagged with the appropriate From email address and creates a ticket for that specific user.
justingoldberg
Posts: 96
Joined: Tue Mar 29, 2011 10:02 pm
Location: Southeast USA
Contact:

Re: Generate an email when a phone is called

Post by justingoldberg »

The only option to get an email 100% of the time is to have it go to voicemail 100% of the time.


You could use netcat (I use fyodor's ncat) to capture the raw cdr log to a text file.

Then with some bash/awk/grep wizardry have it scan for new calls that contain the helpdesk number.
doom1701
Posts: 69
Joined: Tue Sep 20, 2011 6:52 pm

Re: Generate an email when a phone is called

Post by doom1701 »

I'd love to get the raw CDR for many reasons--can you share more detail on how to do that?
justingoldberg
Posts: 96
Joined: Tue Mar 29, 2011 10:02 pm
Location: Southeast USA
Contact:

Re: Generate an email when a phone is called

Post by justingoldberg »

This is the CSV file format (i assume the cdr format uses the same fields)

Id Start Time (mm/dd/yyyy) (hh:mm) Length (hr:min:sec) From CID Name CID Number DNIS Name DNIS Number Port To CID Name CID Number Port PIN Digits TC

Setup the allworx cdr to stream on port 16366. This command will telnet to the server and put the data straight into a file.

download nmap and put it in your path (ncat.exe comes with nmap)

'ncat 192.168.2.254 16366 >> log.txt'

You can then watch the calls live in another window running 'tail -f log.txt'

Tail can be downloaded from gnuwin32.

double arrows >> appends to a file. single arrow > creates a new file.

You can get more advanced and put the date into the filename, have a task that runs at 11:59pm to kill the process (using prcview or pv), and rerun the script the next day five minutes later. I haven't done all that or I would post the script, but I know it's possible. In testing things I've noticed that if I disconnect and immediately reconnect it sometimes says "too many connections", on 48x hardware :shock:


Related threads (for other pbx's but still applicable)

http://www.google.com/search?ix=seb&sou ... R+ncat+cdr
doom1701
Posts: 69
Joined: Tue Sep 20, 2011 6:52 pm

Re: Generate an email when a phone is called

Post by doom1701 »

You're my hero for the day. We've been wondering how to get CDR stored long term. I can probably take what you've shared and figure out a way to get the CDR detail both into a database, and trigger emails at that level.
doom1701
Posts: 69
Joined: Tue Sep 20, 2011 6:52 pm

Re: Generate an email when a phone is called

Post by doom1701 »

The streaming data seems to be a different layout--similar, but not exact. I've got these columns:

Call ID
5 digit number, appears to be a Call Leg ID
1 digit number (1/0), appears to denote Call pickup (1) or Call End (0)
Unix Timestamp (# of seconds past Jan 1, 1970)
Length of call in seconds (only included if call status is 0, otherwise this field is 0)
From MAC
From Directory Name
From CNAME (for inbound calls from outside)
From Phone # (external or extension)
To MAC
To Directory Name
Additional To detail--seems to only be filled in if a call goes to voicemail
To Extension
Blank on every call I pulled--possibly PIN?
Digits Dialed
Not sure, 1 digit field of 0, 1, or 2. May indicate disconnect method (0 appears on all first records of a call leg, and 1 or 2 shows up on the "end" record of a call leg)
Not sure, 1 digit field containing 1 or 2. Most calls are 2, only those calls that were handed off to something (another site, voicemail) else terminate in 1.
Inbound DID Description
Inbound DID

It was pretty straight forward to make a .NET app that read the streaming CDR data. Right now I've got it going to a file, but I can have it output the detail to a SQL database as well. If I write to the database using a stored procedure (or even make use of a trigger), I can have the database generate an email when certain conditions are met.
justingoldberg
Posts: 96
Joined: Tue Mar 29, 2011 10:02 pm
Location: Southeast USA
Contact:

Re: Generate an email when a phone is called

Post by justingoldberg »

You might want to download a trial of CallData to be sure of the fields.
doom1701
Posts: 69
Joined: Tue Sep 20, 2011 6:52 pm

Re: Generate an email when a phone is called

Post by doom1701 »

Tried looking at Calldata (took a day to finally get registered on their site and finally download it). Didn't see any info that I didn't already know, but I couldn't figure out a way to look directly at their mapping.

I did figure out the two "Not sure" fields. The first one is who terminated the call leg. 0 if the call is active, 1 if the caller terminated the call, 2 if the receiver terminated the call. The second unknown column denotes if the call leg is internal only (1) or connects to external resources (2).

I've also, in typical overdoing it fashion, written up a small .NET app that can connect to the streaming port, parse the data, and put that data in a SQL database. The bulk of the intelligence is in the database--a stored procedure takes the info from the parsing app and updates Call and Leg data as legs start and end. The .NET app is pretty portable, the database is a little more complex and I don't know how to generically script it's creation. Someone with a little SQL background could easily create it, though, and I could pass along the script for creating the tables and stored procedure if anyone would like to try it.
jgn1013
Posts: 1
Joined: Thu Apr 10, 2014 4:24 pm

Re: Generate an email when a phone is called

Post by jgn1013 »

if you have the .net code i would like to try using, thanks
doom1701
Posts: 69
Joined: Tue Sep 20, 2011 6:52 pm

Re: Generate an email when a phone is called

Post by doom1701 »

jgn1013, I'm just starting to get active on the forum again. I'll see if I can get the code packaged up and posted somewhere.
Post Reply