SIP configuration and AGI questions

Hello, I have 2 problems that I am unable to solve:

(1)

I have a peer set up in my sip.conf file that needs a username that is equal to the extension I am dialing.

Is there anyway to do this?

i.e. (in extensions.conf)
[my_context]
exten => _1NXXNXXXXXX,1,SomehowSet(my_peer’s username to ${EXTEN})
exten => _1NXXNXXXXXX,2,Dial(SIP/my_peer)

here is my sip.conf file:
[my_peer]
type=peer
nat=yes
host=206.222.243.18
port=5060
context=my_context
secret=********

So if I dial 18005551234@my_context, everything works fine if I have hard-coded that number as the username in my_peer. But I need to change it dynamically after I have the ${EXTEN} and before I actually dial out.

(2)

I would like to use Asterisk to test an IVR (An IVR is one of those “press 1 for foo, press 2 for bar…” systems).

I can do this manually from the console, pressing each option, but I would like to script this if possible.

The problem I have is that every time I dial(SIP/my_IVR), either in an AGI script or in the dialplan, the next command is not executed until the Dial command is done (i.e. they hang up).

What I would really like is a script that does this:
dial my_IVR
press 1
press 2
…additional testing…
hangup from my_IVR

Is this possible?

Thanks in advance.

(1)
you need to change the peer name dynamically? i don’t understand, can you give a working example that would make the problem clearer? you could use an AGI script to get the peer to call. something like:

exten => _1NXXNXXXXXX,1,AGI(getPeerName.php)
exten => _1NXXNXXXXXX,n,Dial(SIP/${variableReturnedByAGI})

or you could NOT put your peers into sip.conf and instead do:

exten => _1NXXNXXXXXX,1,Dial(SIP/${EXTEN}:password@host.com)
(you’ll need to double check the above, but I’m pretty sure you can do it.)

(2)
yes, it’s very possible and easy. you must have some sort of error in your dialplan. post the relevant section.

(1)

My sip.conf peer looks like this:

[my_peer]
type=peer
nat=yes
host=206.222.243.18
port=5060
context=my_context
secret=********
fromuser=abcdefg
fromdomain=my_domain.com

If I have the line
username=+18001234567
in [my_peer], when I dial out it makes my To: header look like this:
To: sip:+18001234567@206.222.243.18;

This is necessary for the host I am connecting to to forward the call properly.

And the catch is that in the
username=+18001234567
the 11-digit number is whatever number I want to be forwarded to… so for every call I make the username is different. (the username would be +${EXTEN}).

But it’s the fromuser and fromdomain that prevent me from doing
exten => _1NXXNXXXXXX,1,Dial(SIP/${EXTEN}:password@host.com)
because then the To: header is correct but the From: header is wrong.

The best solution I can think of is to have an AGI script modify my sip.conf file to set username to whatever ${EXTEN} happens to be for that call.

(2)

I had an AGI script that tried something like
echo "exec dial SIP/my_server"
echo “verbose DONE”

I only see the DONE after the call has been hung up.

I did a similar thing in my extensions.conf file:
exten => 1,1,Dial(SIP/my_IVR)
exten => 1,n,wait(10)
exten => 1,n,Dial(4)

But that is obviously wrong. All I really need to know is how to Dial a number, wait a certain amount of time, and then play a tone (like pressing a number on your telephone).

Thanks

sounds to me like you are having a hard time making some fairly simple things work. have you thought of installing Trixbox? you’d get everything working much more quickly. otherwise you’ll need to read some more documention because everything you ask is explained on the internet. have you been to the links in my signature?

go get trixbox.

by the way, the “+18001234567” in “sip:+18001234567@206.222.243.18” is not the username, but the destination.

Hi,

dial() indeed returns when the call is finished. You can, however, call a macro when the call is established, so the interaction with the remote system should go into the macro.
You will probably need senddtmf() rather than dial to talk to the remote end

Musicman