[asterisk-users] PhpAgi call generation

Anthony Francis anthonyf at rockynet.com
Fri Jun 22 16:41:56 CDT 2007


Nitesh Divecha wrote:
> Thanks Lee,
>
> That really helped me to get my project started... I am in process of 
> developing IVR based Notification System which is going to integrate 
> with my IVR based Time clock system.
>
> Notifications will be based on, if an employee is late to clock in, 
> event should trigger and generate a .call file and call the supervisor 
> and let him know that XYZ employee is late, do you want to inform an 
> employee... etc...
>
> Cheers,
> Nitesh
>
>
>
>
> Lee Jenkins wrote:
>   
>> Nitesh Divecha wrote:
>>   
>>     
>>> Is there any info on how to create .call files with some examples? And 
>>> where to place this file? And how to initiate it..?
>>>
>>> Thanks man...
>>>
>>> Cheers,
>>> Nitesh
>>>
>>>
>>>
>>> Christopher Robinson wrote:
>>>     
>>>       
>>>> That should be pretty easy to do with a .call file.  The context that 
>>>> you drop your called party off to will play the sounds and do the 
>>>> transfer.  So really you need to concentrate on creating that context, 
>>>> the .call files are very easy to generate.
>>>>
>>>>
>>>> Nitesh Divecha wrote:
>>>>       
>>>>         
>>>>> Finally, this is what I was looking for... to generate a call.
>>>>>
>>>>> I have been working on my Time Clock application, where an employee will 
>>>>> call into the system using his cellphone to clock in and clock out his 
>>>>> hours. And it works perfect...
>>>>>
>>>>> Now I was looking for an option where or if an employee is late to clock 
>>>>> in, the system has to generate a call and call the supervisor and inform 
>>>>> him that XYZ employee is late and give an option to supervisor "Would 
>>>>> you like to call XYZ employee, Press 1" and the system will call the XYZ 
>>>>> employee and connect with the supervisor...
>>>>>
>>>>> Is it something feasible to do using the .call files? Or I am way too 
>>>>> off...
>>>>>
>>>>> Cheers,
>>>>> Nitesh
>>>>>
>>>>>
>>>>> Christopher Robinson wrote:
>>>>>   
>>>>>         
>>>>>           
>>>>>> I've done this many times, also used the .call files.  If you don't need 
>>>>>> your application to initiate the call the .call files are the better way 
>>>>>> to go, otherwise it's a bit too much file management overhead.
>>>>>>
>>>>>> Here's some working code on our end.  In this case the Channel is 
>>>>>> actually a context which makes the actual call, but I've used it both ways.
>>>>>>
>>>>>> <?php
>>>>>>   require('PHPAGI/phpagi-asmanager.php');
>>>>>>
>>>>>>   $callid = 'Somebody';
>>>>>>
>>>>>>   $asm = new AGI_AsteriskManager();
>>>>>>   if($asm->connect())
>>>>>>   {
>>>>>>     $call = $asm->send_request('Originate',
>>>>>>             array('Channel'=>"LOCAL/17165555555 at voicepulse",
>>>>>>                   'Context'=>'called_party_context',
>>>>>>                   'Exten'=>'899',
>>>>>>                   'Timeout' => '1000',
>>>>>>                   'Async'=>'1',
>>>>>>                   'MaxRetries' => '5',
>>>>>>                   'RetryTime' => '5',
>>>>>>                   'Priority'=>1,
>>>>>>                   'Callerid'=>$callid));
>>>>>>     $asm->disconnect();
>>>>>>   }
>>>>>> ?>
>>>>>>
>>>>>>
>>>>>> nik600 wrote:
>>>>>>   
>>>>>>     
>>>>>>           
>>>>>>             
>>>>>>> hi
>>>>>>>
>>>>>>> i'd like to write a simply application in php with phpAgi that:
>>>>>>>
>>>>>>> - connect to Asterisk
>>>>>>> - call an external number using a Zap channel
>>>>>>> - play a message
>>>>>>>
>>>>>>> here is some code:
>>>>>>>
>>>>>>> <?php
>>>>>>>
>>>>>>> $asm = new AGI_AsteriskManager();
>>>>>>>
>>>>>>> if ($asm->connect()) {
>>>>>>>
>>>>>>> $asm->Originate("Zap/g1/1","number","default","1");
>>>>>>>
>>>>>>> /*
>>>>>>> play message...
>>>>>>> */
>>>>>>> } else {
>>>>>>>         die("error\n");
>>>>>>> }
>>>>>>>
>>>>>>> ?>
>>>>>>>
>>>>>>> But it doesn't work.
>>>>>>> Is it possible to create a program like this?
>>>>>>> thanks
>>>>>>>             
>>>>>>>               
>> Sorry, I can't help you with PHP.  All my stuff is in pascal.  But here 
>> is a link to call origination info:
>> http://www.voip-info.org/tiki-index.php?page=Asterisk+auto-dial+out
>>
>> I did something a bit like what you're doing, but it was a script to 
>> call into the system and generate a "broadcast" type message to a 
>> different party.  Again, a bit different, but the elements are all the 
>> same; call control, origination, database access, etc. Its in pascal, 
>> but the syntax is very easy to understand and may give you an idea of 
>> how program flow might be.
>>
>> http://www.leebo.dreamhosters.com/apscripts/msgcast/
>>
>>
>>   
>>     
>
>
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users
>   
It should be noted that the above code isn't AGI. its using AMI, the 
Asterisk Manager Interface.

An example of how to use it is:
$message = "Action: Originate\r\n
Channel: Local/3035551212\r\n"
MaxRetries: 5\r\n
RetryTime: 300\r\n
WaitTime: 45\r\n
Context: redalert\r\n
Exten: s\r\n
Priority: 1\r\n
Callerid: 1234\r\n\r\n";

$response=$astman->ast_cli("localhost", $message);

Of course this is using my own custom AMI PHP module, but the elements 
needed to setup a call are the same. This particular call plays a 
recorded message after the phone is answered.




More information about the asterisk-users mailing list