Você está na página 1de 5

Log in or Sign up

HOME ALL CONTENT RESIDENTIAL VOIP BUSINESS VOIP HARDWARE MOBILE VOIP NEWS SPOTLIGHT HOW TO FORUMS MEMBERS

SEARCH FORUMS RECENT POSTS

Home Forums Premiere Hardware Forums Asterisk Support Forum

Need Help in "Appointment" code in Asterisk

Hiall,
Ihavetodesignanappointmentscheduleinasterisk.Say,apatientcallsthedoctor,thenasteriskitselfhastotakethecallandasktheperson's
name,recorditandreadtheintimeandouttimeforthatpersonandupdateindatabase....Uptothispoint,amdone.Now,afteracceptingintime
andouttime,Iwillhavetocheck

a)iftheslotisopen.IfnotyoushouldaskthecallertoenteradifferenttimeItcanbedonethroughdatabasecheck,thisisOK..
padmaja3 b)dosometimevalidations(shouldn'tbetoolate)
c)callershouldevenbeabletocanceltheslotautomatically.Ishoulddoacheckonhisphonenumber.
d)ifthenumberisnotknownfromcallerid(blocked),youshouldprompttheusertoprovideyouwiththenumber.

Hwtomakeit [IMG] ???????????


Plshelpmeinthis,Ifpossibleplssendmesampleprojectcodealso.Ineeditattheearliest.

Expectingafavourablereplyandthanxinadvance............

PadmajaTN.
padmaja3, Sep 21, 2007 #1

HiPadmaja

Ihavecodereturninperldoasimilarstuff,Notanappointmentstuff.

ThiscodeisusedbasicallytoscheduleafutureCall
eg:IliketocallmymomsometimeinfutureandIscheduleitnowandSystemwilltakecaretherestconnectingmeandmymomoncorrect
jsree time.

thescriptbasicallygetDestinationNumber,date,time,minutesfromtheuser,ifyouareinterestedIcanpostthecode.

thanks
Jay
jsree, Sep 25, 2007 #2

ThanksalotJay.
Plssendittopadmaja6@gmail.com.
I'llbegratefultoyou.

padmaja3, Sep 25, 2007 #3


padmaja3
futureCall.agi

#!/usr/bin/perlw
#
useDigest::MD5qw(md5_hex)
useTime: arseDate()
jsree if(!eval"requireAsterisk::AGI"){
print"VERBOSE\"***PerlModuleAsterisk::AGINOTINSTALLEDseedocumentation***YourphonesystemWILLNOTWORK\"0\n"
exit
}
if(!eval"requireTime: arseDate"){
print"VERBOSE\"***PerlModuleTime: arseDateNOTINSTALLEDseedocumentation***YourphonesystemWILLNOTWORK\"0\n"
exit
}
my$debug=4
my%ext#Hashthatwillcontainourlistofextensionstocall
my%ext_hunt#Hashthatwillcontainourlistofextensionstocallusedbyhuntgroup
my$cidnum#CallerIDNumberforthiscall
my$cidname#CallerIDNameforthiscall
my$timer#CalltimerforDialcommand
my$dialopts#optionsfordialing
my$rc#Catchreturncode
my$priority#Nextpriority
my$rgmethod#IfRingGroupwhatringingmethodwaschosen
my%config#Contentsof/etc/amportal.conf
my$AGI=newAsterisk::AGI
my%input=$AGI>ReadParse()
$AGI>setcallback(\&mycallback)

$cidnum=$input{'callerid'}
$type=$input{'type'}
debug("Type:$type",1)
if($debug>=2){
foreach$key(keys%input){
debug("$key=".$input{$key},1)
}
}
my($phone,$year,$month,$date,$hour,$minute)
my($csec,$cmin,$chour,$cday,$cmon,$cyear,$cwday,$cyday,$cisdst)=localtime(time)
my@months=qw{januaryfebruarymarchaprilmayjunejulyaugustseptemberoctobernovemberdecember}

$AGI>answer()
my$cidchannel=$AGI>database_get("DEVICE/$cidnum",'dial')
if(!defined$cidchannel){
my($pwd)=&get_data("PleaseEnterpasswordfollowdbyPoundkey.",3000)
&get_data("GoodBye")if$pwd!=2222
$AGI>hangup()if$pwd!=2222
exitif$pwd!=2222
}
my$sid=0
my$cnt=0
while($sid!=1){

$phone=undef
debug("Getthetelphoen",1)
while(!defined$phone){
($phone)=get_data('Entertheoutgoingnumberfollowedbypoundkey.',10000)
}
($year)=get_data("Entertwodigitforyear.","3000",2)

($month)=get_data("Entertwodigitsformonth.","3000",2)

($date)=get_data("EntertwodigitsforDate.","3000",2)

($hour)=get_data("Entertwodigitsforhour","3000",2)

($minute)=get_data("Entertwodigitsforminute","3000",2)

$year=$cyearif!defined$year
$month=$cmon+1if!defined$month
$date=$cdayif!defined$date
$hour=$chourif!defined$hour
$minute=$cmin+10if!defined$minute
$year=$year%100
$year+=2000
$sid=undef
my$digit=$date%10
my$ad='th'
$ad='st'if$digit==1
$ad='nd'if$digit==2
$ad='rd'if$digit==3

my$phoneCopy=$phone
my@digits=qw{Oonetwothreefourfivesixseveneightnine}
my$phoneStr=''
while($phoneCopy){
$phoneStr=sprintf("%s%s",$digits[$phoneCopy%10],$phoneStr)
$phoneCopy=int($phoneCopy/10)
}

my$swiftxt="Youliketocallphone$phoneStron$year$months[$month1]${date}${ad}at$hour$minute"

while(!defined$sid){
my($rc,$file)=get_data($swiftxt)
($sid)=get_data("Press1forYes2forNo.","1000",1)
unlink$fileifdefined$sid
}

}
my$firstChannel=$AGI>database_get("DEVICE/$cidnum",'dial')
$cidnum="1".$cidnumiflength$cidnum==10
$firstChannel="Zap/1/$cidnum"if!defined$firstChannel

$cidnum.='@outboundallroutes'if$typeeq'Local'
my$channel=$AGI>database_get("DEVICE/$phone",'dial')
debug("Channel$channel",1)ifdefined$channel
my$context='outboundallroutes'
$context="frominternal"ifdefined$channel
$phone="1".$phoneiflength$phone==10

my$dial=<<EOF
Channel:$firstChannel
CallerId:$phone
MaxRetries:5
RetryTime:60
WaitTime:30
Context:$context
Extension:$phone
Priority:1
EOF

my$digest=md5_hex($cidnum.$phone.$minute.$csec)
my$filename="/var/tmp/call_".$digest
my$outgoing="/var/spool/asterisk/outgoing/call_".$digest

$filename.="_$minute"."$csec"
debug("$filename$ttime",1)

openPR,">$filename"ordebug("Unabletoopenthefile$filename:$!",1)
printPR$dial
closePR
$year=2000
my$future_time=$month.'/'.$date.'/'.$year."$hour:$minute:00"
debug($future_time,1)
my$utime=Time: arseDate: arsedate("$future_time",NO_RELATIVE=>1)
my$ctime=time
$ctime+=120
debug("$ctime$utime",1)
if($utime>$ctime){
utime$utime,$utime,$filename
my($login,$pass,$uid,$gid)=getpwnam('asterisk')
chown$uid,$gid,$filename
rename$filename,$outgoing
&get_data("GoodBye")
}else{
&get_data("Itistoolateschedulethiscall")
}
$AGI>hangup()
exit0

subdebug
{
my$string=shift
my$level=shift||0
if($debug){
$AGI>verbose($string,$level)
}
return(0)
}
submycallback
{
my$rc=shift
debug("Userhungup.(rc=".$rc.")",1)
exit($rc)
}

subget_data{
my($txt,$timeout,$digits)=@_
my$hash=md5_hex($txt)
my$sounddir="/var/lib/asterisk/sounds/tts"
my$trmwfile="$sounddir/"."tts_trim$hash.wav"
my$swiftbin="/opt/swift/bin/"
my$twfile="tts/tts_trim$hash"
unless(f$trmwfile){
my$execswift=$swiftbin."swiftnDavid8kHzo$trmwfile\"$txt\""
system($execswift)

return($AGI>get_data($twfile,$timeout,$digits),$twfile)ifdefined$digits
return($AGI>get_data($twfile,$timeout),$twfile)ifdefined$timeout
return($AGI>stream_file($twfile,1),$twfile)
}

Pleaseaddfollowinglineextensions.conf

exten=>732,1,AGI(futurecall.agi)
exten=>732,n,Wait,2
exten=>732,n,Hangup

Hopethiswillhelpyou

Jay
jsree, Sep 26, 2007 #4

Thanksaton,Jay.
Thiswilldefinitelydo.

padmaja3, Sep 26, 2007 #5


padmaja3

(You must log in or sign up to reply here.)

Share This Page


Tweet 0 Like Be the first of your friends to like this.

Home Forums Premiere Hardware Forums Asterisk Support Forum

Default Style Help


Forum software by XenForo 20102015 XenForo Ltd. Terms and Rules

Você também pode gostar