Connectedline for voicemail and others

When a user hits the voicemail button on the phone, the *97 number is displayed, of course. I’d like to make it just a little bit more user friendly, and have it display “Voice Mail” also.

This can be done with the ‘connectedline()’ command in the dialplan, and this is what I’ve added to extensions_custom.conf

exten => _*97,1,Set(CONNECTEDLINE(number,i)=*97)
same => next,Set(CONNECTEDLINE(name,i)=Voice Mail)
same => next,Set(MAILBOX=${SIPPEER(${CHANNEL(peername)},mailbox)})
same => next,VoiceMailMain(${MAILBOX},s)
same => next,Hangup(normal_clearing)

But that’s quite a lot for a small thing, especially as I’d like to add more ‘friendly names’ for system features. There has to be a better way.
Any suggestions?

also, I’ve come to realise that I don’t really understand what the underscore is for before the matched number, and it’s quite hard to google for! Would love an explanation for that one :slight_smile:

https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching

Ah, The underscore prefix allows the use of pattern matching. So the particular example above does not need it. I’ll remove it.
Thanks for the tip.

Extension names are not limited to single specific extension “numbers”. A single extension can also match patterns. In the extensions.conf file, an extension name is a pattern if it starts with the underscore symbol (_).

Why not open a feature request for this and provide patches for this along with other feature codes. issues.freepbx.org

Happy to. But, I’m guessing that you don’t want a few hundred lines of _custom.conf, right :slight_smile:

The right way, assuming that there’s not something I’m missing, would be to have the conf generation ‘engine’ include the two key lines right into the correct place in the dial plan for each code. That would seem to be neater. That would mean modifying the _additional.conf files and I’ve not checked into how those are generated. Is there something on the wiki giving a good overview or is it more a case of find a weekend and a bottle of scotch and start digging?

Cheers!

I think I’ve found a better way to implement this.
On your mobile phone, if you dial a person by number, rather then picking their entry in the contacts list, it will match the number to their name (if it’s there of course) Asterisk/FreePBX does not.

But it does do it for inbound calls.

So the fix is simple, make outbound calls lookup the dialled number against a superfector scheme, and add the match to the connectedline string. Then just add *97-VoiceMail into the phonebook.

Of course, *97 cannot be stored in the phonebook as it does not pass the regex checking, but that’s a minor issue, they could be stored anywhere. As a concept, it provides ‘naming’ of numbers with more flexibility and language support without making lots of changes to core files.

I think this’ll end up being an option on outbound routes, as a sensible location for it. More code to investigate!

I would say we should actually do this right and in feature code admin define the name you want displayed on phone when dialing the feature code. By default you can provide standard names like Voicemail or Echo Test for example but users could change this.

Agreed, the feature code table already holds a description, but some of those could be a bit long, so a partner field ‘shortDescription’ that is user editable could well solve the ‘where to store the names’ issue nicely.

A superfecta source to read that table would be needed, then it’s would be a case of make a superfecta scheme that would look at whatever sources were appropriate (feature codes, phone books etc) and call this from outbound routes and internal calls.

Took a quick look at this for the part I saw to be the simplest, emulating the behaviour of a mobile phone.
I already had a hook in extenstions_custom.conf for outbound calls, to disable video calling, which was simply:

; ----- External calls, lock codec to prevent video
exten => _0.,1,Set(__SIP_CODEC=alaw)
same => next,Goto(outbound-allroutes,${EXTEN},1)

So I checked for how inbound calls were handled with regard to looking up the name of the caller, and copied in a couple lines of code, to make it now:

; ----- External calls, lock codec to prevent video
exten => _0.,1,Set(__SIP_CODEC=alaw)
same => next,AGI(/var/www/html/admin/modules/superfecta/agi/superfecta.agi)
same => next,Set(CONNECTEDLINE(name,i)=${lookupcid})
same => next,Goto(outbound-allroutes,${EXTEN},1)

and of course, it didn’t do anything at all. The superfecta code is looking up based on the CNUM value, which for this outbound call is my extension, so that won’t work, I need it to look up the number that I called, not the number I called from. Time for a dirty hack:

; ----- External calls, lock codec to prevent video
exten => _0.,1,Set(__SIP_CODEC=alaw)
same => next,Set(CALLERID(num)=${EXTEN})
same => next,AGI(/var/www/html/admin/modules/superfecta/agi/superfecta.agi)
same => next,Set(CONNECTEDLINE(name,i)=${lookupcid})
same => next,Goto(outbound-allroutes,${EXTEN},1)

So I overwrite the number I’m calling from with the number that I called, then pass that to the superfecta, which does it’s job perfectly and returns a name. The name is then passed back to the phone by updating the Connectedline name, and bingo! Working names appear for recognised outbound numbers. (disclaimer: not actually tested on a phone, looking at asterisk console only for results)

Pretty sure this was a bad idea though, so I checked the CDR data and sure enough, it makes a mess of it. Where it should show “UserName” <exten> it now of course shows “UserName” <dialledNumber>

So I’ll not be keeping it, but as a proof of concept it works and I like the behaviour.

In order to not screw up the CDR, I’ll need to modify the superfecta code so it can understand what I’m trying to do.

It normally is called by an inbound call, and looks up based on the CNUM, I’m wondering if there’s a way for it to detect an outbound call is being make, and look at the DID instead?

Or perhaps it would make more sense to define a different scheme, and call that scheme, but I didnt see a way to specify which scheme I wanted to use via the dialplan.

Either way, this does not address my starting point of ‘naming’ the feature codes, but it’s a start.

Thoughts, comments?

Two updates. Tested on the hardware ad with the Cisco phones I’m using, the display is only updated with the name when the call is answered, which is sub-optimal.
[EDIT: removing the incorrect use of ,i from the commands causes the phone to update the display promptly and now behaves as expected]

“fixed” the CDR issue by storing and replacing the CID rather than just overwriting it, and added the connected line number as well as the name to give the deserved affect.

The code block is now below, and while it’s still a hack, it can be left running now as it does not break the CDR

; ----- External calls, lock codec to prevent video and update screens with CID lookup if available
exten => _0.,1,Set(__SIP_CODEC=alaw)
same => next,Set(storeDialedNumber=${CALLERID(all)})
same => next,Set(CALLERID(num)=${EXTEN})
same => next,AGI(/var/www/html/admin/modules/superfecta/agi/superfecta.agi)
same => next,Set(CALLERID(all)=${storeDialedNumber})
same => next,Set(CONNECTEDLINE(number,i)=${EXTEN})
same => next,Set(CONNECTEDLINE(name,i)=${lookupcid})
same => next,Goto(outbound-allroutes,${EXTEN},1)

http://issues.freepbx.org
patches always welcome.

I dropped it into issues already.
As getting this ‘just right’ without breaking things may be a little tricky, I’m not planning to offer a full solution for the just yet. Still trying to find my way around who the whole framework fits together.
If it’s not been picked up by the time I’m up to speed, I’ll sort it :slight_smile: