How to work with BlackList? - asterisk

I am new to asterisk. i am working under ubuntu 9.10. I use asterisk 1.8. I want to create a conference room.
in meetme.conf
conf => 1234,1234
in extensions.conf
exten =>1234,1,MeetMe(1234)
Is the pin number a secure one? How to create a secure pin number (do i have to use numbers and characters too)? Secondly how to create a blacklist? If a person tries to register 3 times..and the passed is incorrect how can I put him/her on the blacklist?

Passwords are numbers, however, '1234' is not a good password choice.
Asterisk's dialplan is extremely dynamic; there is no single definition of 'Blacklist'. However, try something like this:
== meetme.conf
conf => 1234
== extensions.conf
exten => 1234,1,GotoIf(${BLACKLIST()}?hangup)
exten => 1234,n(loop),Set(TRIES=$[0${TRIES} + 1]);
exten => 1234,n,GotoIf($["$TRIES" = "3"]?blacklist)
exten => 1234,n,Read(PIN,enter-conf-pin-number,4)
exten => 1234,n,GotoIf($["$PIN" = "9999"]?meetme)
exten => 1234,n,Goto(loop)
exten => 1234,n(meetme),MeetMe(1234)
exten => 1234,n,Hangup
exten => 1234,n(blacklist),Set(CALLERID(num)=${FILTER(0-9\-,${CALLERID(num):-10})})
exten => 1234,n,Set(DB(blacklist/${CALLERID(num)})="Some Comment")
exten => 1234,n(hangup),Hangup
there are all sorts of other ways. this particular setup will only keep the caller from trying to authenticate into that one conference room. if you'd rather ban him from ever touching your automated attendant, you can move the first line to your incoming context.
If you're already sanitizing your callerid (you should be) you can remove the FILTER line and bump the (blacklist) to the next line.

Related

Asterisk block incoming call from specific country only

I am trying to make a dial plan to block incoming call coming from let say bangladesh where country code is 88
Here is my dial plan
exten => _X.,1,NoOp(${CALLERID(num)})
same => n,Set(regx=^(88)[0-9]$)
same => n,GotoIf($[${REGEX("${regx}" ${CALLERID(num)})} = 1]?blacklisted,s,1)
same => n,Dial(SIP/8.8.8.8/${EXTEN}
[blacklisted]
exten => s,1,Wait(9)
what i want to do is anything that comes from 88 should be sent to blacklist. At the moment if I test call with Caller ID 88 it works but if the call comes from 88XXXXXXX this does not work what can I do to make my dial plan block anything coming from 88XXXXXXXX to goto black list
Why do you use the complex REGEX function? Just do something like that:
exten => _X.,1,NoOp(CallerID is: ${CALLERID(num)})
exten => _X.,n,Set(number=${CALLERID(num)})
exten => _X.,n,ExecIf($[${number:2} = 88],Hangup())
exten => _X.,n,NoOp(Call is being continued)
This will save the callerid num into the "number" variable. Then it will check if the first 2 characters of the variable are equal to 88. If so, the call will be hung up. You can also use GoToIf instead of ExecIf if you want to send the blacklisted call to a specific context where you want to do something else with it.
Asterisk dialplan is regexp itself. Why you use other regexp?
exten => _X.,1,NoOp(${CALLERID(num)})
same => n,Gosub(cid-blacklist,${CALLERID(num)},1)
same => n,Dial(SIP/8.8.8.8/${EXTEN}
[cid_blacklist]
exten => _88.,1,Noop(bangladesh)
same => n,Wait(100)
; this works only when not found match in context.
include=> cid_blacklist_not_found
[cid_blacklist_not_found]
exten => _X.,1,Return;not found in cid blacklist

Googl ASR integration using UniMRCP for two way communication

I wanted to capture all the voice conversation between customer and agent in text format.
I have done the integration with Asterisk and Google Speach-to-Text using UniMRCP. I'm successfully able to capture customer side speech only but I wanted to captured agent's conversation too.
Sample dialplan:
exten => s,1,Answer()
exten => s,2,Originate(SIP/101,exten,google,s,3)
exten => s,3,SpeechCreate()
exten => s,4,SpeechActivateGrammar(builtin:speech/transcribe)
exten => s,5,SpeechBackground(beep, 20)
exten => s,6,Verbose(1, "Recognition result count: ${SPEECH(results)}")
exten => s,7,GotoIf($["${SPEECH(results)}" = "0"]?7:9)
exten => s,8,Playback(error)
exten => s,9,Goto(3)
exten => s,10,Verbose(1, "Recognition result: ${SPEECH_TEXT(0)}, confidence score: ${SPEECH_SCORE(0)}, grammar-uri: ${SPEECH_GRAMMAR(0)}")
exten => s,11,SpeechDestroy()
I want to save both parties communication in a text format need suggestion on dialplan part to achieve the same.
Simplest way - send both parties to conference(see n-way-calling howto) and listen to conference.
You also can use ChanSpy

Remove chars from number dialplan asterisk

How to remove first 3 digits/letters from CALLED NUMBER. Let's say number 123456789 calls to abc987654321. I want to remove abc because in the context I have only 987654321. I know how to cut from CALLER but don't know how to cut from CALLED(Destination) number. This is what I tried so far but nothing happen:
exten => _[a-z]XXXXXXXXXXXX,1,Set({CALLEDID}=${CALLEDID:3})
exten => _[a-z]XXXXXXXXXXXX,2,Dial(SIP/${CALLEDID},1)
exten => _[a-z]XXXXXXXXXXXX,3,Voicemail(${CALLEDID}#VoiceMail)
exten => _[a-z]XXXXXXXXXXXX,4,Playback(Goodbye)
exten => _[a-z]XXXXXXXXXXXX,5,Hangup
You can use FILTER function or just do goto. You not need cut from destination,you need cut from extension.
exten => _[a-z]XXXXXXXXXXXX,1,Goto(${EXTEN:3},1)
exten => _XXXXXXXXXXXX,1,Dial(SIP/${EXTEN},1)
exten => _XXXXXXXXXXXX,n,Voicemail(${EXTEN}#VoiceMail)
exten => _XXXXXXXXXXXX,n,Playback(Goodbye)
exten => _XXXXXXXXXXXX,n,Hangup
Please note, your dialplan still do voicemail if called part hanguped after call. Read default extensions.conf.sample to see how to deal with voicemail

Asterisk "monitor" command records calls but throws away recorded files on premature hangup

I am using the "monitor" command to record full calls. This works well, but only when the user goes through the entire callflow. I tried monitoring the recorded file size as the call progresses. Once the call starts, the file sizes start increasing (of both the "in" and "out" sides of the call). However, if the user hangs up prematurely in the middle of the call, whatever has been recorded thus far is inexplicably dropped and stubs (44 bytes) are left in its place. Any insight into why this behavior occurs will be appreciated.
I am reproducing a snippet from the dialplan I used in my extensions.conf file below:
exten => 7611,1,Answer()
exten => 7611,n,Playback(/var/lib/asterisk/sounds/custom/transferring_with_record_wa rning)
exten => 7611,n,Set(GROUP()=outgoing)
exten => 7611,n,NoOp(The current group count : ${GROUP_COUNT(outgoing)})
exten => 7611,n,GotoIf($[${GROUP_COUNT(outgoing)}>1]?15)
exten => 7611,n,Set(GLOBAL(current_timestamp_7611)=${STRFTIME(${EPOCH},GMT+1,%s)})
exten => 7611,n,Set(GLOBAL(current_full_format_timestamp_7611)=${STRFTIME(${EPOCH},G MT-8,%d%m%Y_%H%M%S)})
exten => 7611,n,NoOp(The current timestamp : ${current_timestamp_7611})
exten => 7611,n,NoOp(The last timestamp : ${last_timestamp_7611})
exten => 7611,n,GotoIf($[(${last_timestamp_7611}+20>${current_timestamp_7611})]?15)
exten => 7611,n,NoOp(All cases passed)
exten => 7611,n,Ringing()
exten => 7611,n,Wait(2)
exten => 7611,n,Monitor(wav,HALEF_audio_ext_7611_${current_full_format_timestamp_761 1})
exten => 7611,n,Dial(SIP/1200#JVXML97,,XgF(default^7611^14))
exten => 7611,n,Set(GLOBAL(last_timestamp_7611)=${STRFTIME(${EPOCH},GMT+1,%s)})
exten => 7611,n,Hangup()
exten => 7611,n,Ringing()
exten => 7611,n,Wait(2)
exten => 7611,n,Playback(/var/lib/asterisk/sounds/custom/busy_later)
exten => 7611,n,Wait(1)
exten => 7611,n,Hangup()
I understand that the "record" command has a "k" parameter which keeps the recorded file upon hangup, but I'm not able to find any similar functionality with the Monitor command. (I'd use "record", but I'd like to record the full call (duplex) and do it automatically, without any user input requirement).
Thanks!
Use MixMonitor command.
Check you have permissions needed for write files.
Check debug if you unsure.
PS. using diaplan WITH n, without labels and goto to EXACT priority is very bad practice, can result hard-catchable bugs. Using GLOBAL variables without need also not so nice idea.

Waiting for extra digit when it's clear that there's no other matching rule

I'm a beginner on Asterisk, but already have my PBX working connected to the PSTN. The issue I'm having is that I have this rule
exten => _*X.*,1,Log(DEBUG, Calling through provider one to ${EXTEN:1:-1})
same => n,Dial(SIP/${EXTEN:1:-1}#oneProvider,60)
There are no other extensions that start with *. What I want to achieve is to dial out as soon as the second * is pressed (and there's nothing the user can press to go to a valid extension), right now it waits a few seconds and dial. I also tried adding ! at the end of the extension, but nothing changed.
Am I missing something? Is this feasible?
Thanks!
This task is not doable in current asterisk.
It will not work beacuase * matched .(dot) in your dialplan.
Except dialplan like this(very ugly one beacuase it will go dialplan for every new digit)
[originalcontext]
exten => *,1,Goto(collect_number,s,1)
[collect_number]
exten => s,1,WaitExten(); wait for single digit
exten => *,1,Set(stars=${stars}*);save stars
exten => *,2,GotoIF($[ "${stars}" == "**" ]?dial,1); if 2 star already,go dial.
exten =>_X,1,Set(digits=${digits}${EXTEN});save digits
exten => _.,3,WaitExten(); wait enother input;
exten => _.,4,Goto(dial,1); go dial if no new digits
exten => dial,1,Dial(SIP/${digits}#oneProvider,60)
Correct solution - use Read application and ask user use # to end number instead of *.
You also can try dialplan like this:
exten => _*X*!,1,Goto(dial,${EXTEN:1:-1},1)
exten => _*XXX*!,1,Goto(dial,${EXTEN:1:-1},1)
exten => _*XXXX*!,1,Goto(dial,${EXTEN:1:-1},1)
exten => _*XXXXX*!,1,Goto(dial,${EXTEN:1:-1},1)
exten => _*XXXXXX*!,1,Goto(dial,${EXTEN:1:-1},1)
exten => _*XXXXXXX*!,1,Goto(dial,${EXTEN:1:-1},1)
exten => _*XXXXXXXX*!,1,Goto(dial,${EXTEN:1:-1},1); continue upto max number length
[dial]
exten =>_.,1,Dial(SIP/${EXTEN}#oneProvider,,);
But i not fully sure that will work. If works, will be less load(but more lines)

Resources