[asterisk-users] How to recognize a name spelled letter by letter ?

A J Stiles asterisk_list at earthshod.co.uk
Wed Mar 23 08:38:26 CDT 2016


On Wednesday 23 Mar 2016, Olivier wrote:
> Hello,
> 
> I'm wonddering if it is possible, with Asterisk and any third party module
> or service, to build the following feature:
> 
> - caller dials a given extension dedicated to a given language (german,
> english, ...)
> - Asterisk plays a welcome audio prompt
> - caller spells his or her first name letter by letter (for example, caller
> spell "A", "L", "I", ...)
> - Asterisk repeats spelled letters to caller.
> 
> If possible, which module is needed ?
> 
> Best regards

Well, I'd do the whole thing in Dialplan  (it's fairly computationally-
complete per Church and Turing),  but I'm a masochist like that :p

What you need to do is have an inner loop; in which you use WaitExten() with a 
short timeout to read a digit.  If a digit is pressed within the timeout, you 
will get directed to another extension.  There you need to compare the digit 
just pressed against the last digit pressed; and if it is the same, then you 
select the next letter on that key.  Otherwise you announce the last letter 
selected, append it to the name so far, and select the first letter on that 
key.  If you timeout, then you announce the currently selected letter, append 
it to the name so far and set no letter selected.  (This is needed, because 
you may have two letters in succession on the same key; so you must allow it 
to timeout before you can enter the next letter.)  If you timeout with no 
letter selected, you increase a counter; and if this gets to some critical 
number, you repeat the prompt:  Background() the original announcement to 
spell their name, and announce the letters entered so far.  If the 1 key is 
pressed once, backspace  (and after the timeout, announce the remaining 
letters);  two presses within timeout clears the name entered so far and 
starts again from scratch.


So, for example, someone might enter:
2 [set current letter to "A"]
(user waits for timeout) [Store and say "A". Set current letter to ""]
5 [Set current letter to "J"]
5 [set current letter to "K"]
5 [set current letter to "L"]
4 [4 != 5, so store and say "L". Set current letter to "G"]
4 [set current letter to "H"]
4 [set current letter to "I"]
7 [7 != 4, so store and say "I". Set current letter to "P"]
7 [set current letter to "Q"]
7 [set current letter to "R"]
7 [set current letter to "S"]
6 [6 != 7, so store and say "S". Set current letter to "M"]
6 [set current letter to "N"]
6 [set current letter to "O"]
(User waits for timeout) [Store and say "O". Set current letter to ""]
6 [set current letter to "M"]
6 [set current letter to "N"]
* [store and say "N". We now have "ALISON". Go to next context]

For the sake of your own sanity  (or that of your unlucky successor),  use 
maningful labels in your GoToIf() statements; and be sure to comment the 
resulting code liberally, so it looks a little bit less of an unwholesome 
mess.


-- 
AJS

Note:  Originating address only accepts e-mail from list!  If replying off-
list, change address to asterisk1list at earthshod dot co dot uk .



More information about the asterisk-users mailing list