[asterisk-users] Verification number / code
Steve Edwards
asterisk.org at sedwards.com
Sun Nov 22 16:55:03 CST 2009
Un-top-posting...
>> On Sat, 21 Nov 2009, Thomas Perron wrote:
>>
>>> I want to distribute a random number to each of the first 100 callers
>>> to my IVR. This random number will be matched to their telephone
>>> number. Where in Asterisk can I do this? And, how?
>>>
>>> Logic.
>>>
>>> Call arrives. Context for announcement begins. You will receive a
>>> authentication code at the end of the message. Then, if they press a
>>> certain digit to confirm then I simply pass a code to them. These
>>> codes are distributed to the first 100. The 101st call does not get a
>>> code.
> On Sat, Nov 21, 2009 at 7:20 PM, Steve Edwards
> <asterisk.org at sedwards.com>wrote:
>
>> I'm guessing you really don't want a random number since a random
>> number generator can generate duplicates.
>>
>> "Matching" the number to their ANI also has issues. What if my ANI is
>> blocked? What if I spoof my ANI? What if I call from a SIP phone?
>>
>> I would "pre-compute" the random numbers and store them in a database.
>>
>> When a call arrives, I would invoke an AGI that would lock the table,
>> read the first value with a null ANI, update the row with the caller's
>> ANI, and unlock the table.
>>
>> You could do it in dialplan, but I find database access in dialplan
>> ugly.
>>
>> Alternatively, you could mung UNIQUEID (<number of seconds since
>> Epoch>.<number of channels created by this instance of Asterisk>) to
>> appear to the caller as random and then store that and their ANI in a
>> database.
>>
>> What happens if Asterisk is restarted in the middle of your campaign?
On Sat, 21 Nov 2009, Thomas Perron wrote:
> that is a bit heavy for me. how about some simple way to announce a
> random number. using RAND. and saydigit
>
> exten => s,1,Set(junky=${RAND(1,8)})
Um. OK. Use RAND and saydigit. And use some sort of counter to know when
you've issued 100 numbers.
But...
) You may have duplicate random numbers.
) You may have issues counting the callers if you have more than 1 call
arrive at close to the same time.
) If Asterisk restarts, how will you know how many numbers have been
issued?
) You still have to handle the "matching" requirement.
I still think a "databased*" approach is the best approach. I'm sorry it's
not within your current skill-set. Maybe this means you should invest some
time learning the skills or hire someone who has them.
If this is a toy ("Guess a number..."), use RAND and saydigit. If this is
a contest with some sort of prize or involves anything of value, use a
database.
*) MySQL has a really neat generic lock facility that will come in handy.
See get_lock(lock-name, timeout).
--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
More information about the asterisk-users
mailing list