[asterisk-users] Urgent help = RUBY & AGI

Zarko Zivanovic outlaw011 at gmail.com
Wed Jul 28 03:36:16 CDT 2010


Update on this - breaktrough! :-)

 

Finally, I was able to do it. Yes you were right again as you said, I saw
that you mentioned using macros but for some reason I thought that macros
were not available in asterisk 1.2...

 

So what I managed to do is o start a macro and get info about the channel
that picked up the call. 

Also, as said in the thread, i was able to start moh beside the macro and it
all works like charm.

 

The only thing that I cant do so far, is capturing the ${CHANNEL} variable
in the ruby script that started the macro.

 

Is that variable accessible from the ruby script too or just from the macro?

 

Here's a snippet from my ruby script:

 

 

                        dial_params << "||M(testing)m(moh-0900-#{@moh_id})"
if moh_available?()

 

                        1.times do

                                r = $agi.exec('DIAL', dial_params)

                                r = $agi.get_variable('DIALSTATUS')

                                retry if r.message.include?('BUSY')

                        end


 

and further below:

 

$loc = "testing"

                                                

                                $my.query("UPDATE call_log SET
local='#{$loc}', endtime = NOW() WHERE id = #{call_log_id}")

 

Works fine, but as soon as I try:

 

$loc = ${CHANNEL} or something like that - it breaks. Any idea how to pass
that ${CHANNEL} to my ruby script and use it to update DB in that query?

 

 

Thanks a bunch !

 

 

 

 

 

 

From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Jim Dickenson
Sent: Tuesday, July 27, 2010 5:31 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] Urgent help = RUBY & AGI

 

I have never used 1.2.9.1 or anything in the 1.2.x range so I can not give
you an exact solution but I can tell you that the script that you are using
will not work. In the dial command you need to add the M option which will
call a macro when the call is connected. In that macro you can then find the
channel that answered the call and do what you want from there. You can call
another AGI or set variables or whatever. If agi.exec works like a dialplan
step then the dial step will hang if the call is answered and the
agi.get_variable statement will not execute unless the call was not
answered.

 

 

Try

 

r = $agi.exec('DIAL', SIP/voipuser&Zap/32&Zap/33&Zap/34&Zap/35,,M(testing))

 

And then have something like this in extensions.conf

 

[macro-testing]

exten => s,1,DumpChan()

 

You will see that this macro runs when the call is answered and you will see
on the CLI all the variables that are available to you. ${CHANNEL} will have
SIP/ voipuser-e989 in your example below.

-- 

Jim Dickenson

mailto:dickenson at cfmc.com

 

CfMC

http://www.cfmc.com/

 

 

 

On Jul 27, 2010, at 7:21 AM, Zarko Zivanovic wrote:





Here's something that should be easy for RUBY pro's.

 

Here is a script:

 

                        1.times do

                                r = $agi.exec('DIAL',
SIP/voipuser&Zap/32&Zap/33&Zap/34&Zap/35)

                                r = $agi.get_variable('DIALSTATUS')

 

                        #       $agi.set_variable(' WHOANSWERED ',...)

 

                                retry if r.message.include?('BUSY')

                        end 

 

 

when it's executed it shows this in the console:

 

 

 

AGI Rx << ANSWER

AGI Tx >> 200 result=0

AGI Rx << EXEC DIAL SIP/voipuser&Zap/32&Zap/33&Zap/34&Zap/35

    -- AGI Script Executing Application: (DIAL) Options:
(SIP/voipuser&Zap/32&Zap/33&Zap/34&Zap/35)

    -- Called voipuser

    -- Called 32

    -- Called 33

    -- Called 34

    -- Called 35

    -- Zap/32-1 is ringing

    -- Zap/33-1 is ringing

    -- Zap/34-1 is ringing

    -- Zap/35-1 is ringing

    -- SIP/voipuser-e989 is ringing

    -- SIP/ voipuser-e989 answered Zap/1-1   

 

 

What we need is to be able to populate the variable WHOANSWERED with info
SIP/ voipuser

In this case, or whoever answers next time.

 

Thanks in advance!

 

 

 

 

 

 



__________ Information from ESET NOD32 Antivirus, version of virus signature
database 5317 (20100727) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
              http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users

 



__________ Information from ESET NOD32 Antivirus, version of virus signature
database 5318 (20100727) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100728/8cb7fb6d/attachment.htm 


More information about the asterisk-users mailing list