Help with dial plan for call interception via channel bank

Ok, here’s the setup:

We have software that’s configured to dial a phone number, but can only do so by using a modem on the client machine (no VoIP.)

What I’ve got set up:

Modem plugs into a Rhino FXS channel bank. Channel bank plugs into a Rhino R4T1, other ports on the card are connected to two PRI circuits. Each client machine has an IP phone.

What I’d like to do:

I’d like to capture the number dialed by the modem, then dial the client IP phone, dial the number via PRI and bridge the calls.

Any ideas? I’m not quite sure where to start on this one.

Here’s what I have so far:

In Zapata.conf I’ve got:

[channels]
signalling=fxo_ks
group=11
context=user-101
immediate=yes
channel => 1

and in extensions_custom.conf I’ve got:

[user-101]
exten=>s,1,Answer()
exten=>s,n,Playtones(350+440)
exten=>s,n,Read(NUMBER,12)
exten=>s,n,SayNumber(${NUMBER})
exten=>s,n,Hangup()

And this works. Where I’m getting hung up now is how I dial the numbers and bridge them.

For example, after I read NUMBER, I should dial SIP/101 and ZAP/g0/(${NUMBER}) and connect them.

Any help?

Looks like this isn’t possible using just the dial plan, and I’ll have to break out into AGI and use originate. Not a huge problem.

If anyone cares, I got somewhere:

In extensions_custom.conf do:

[user-101]
exten=>s,1,Answer()
exten=>s,n,Playtones(350+440)
exten=>s,n,Read(NUMBER,,12)
exten=>s,n,StopPlayTones()
exten=>s,n,DeadAGI(cbdial.agi,${NUMBER})
exten=>s,n,HangUp()

And cbdial.agi is:

#!/usr/bin/perl -w
use IO::Socket::INET;
use strict;
$|=1;
my $num=$ARGV[0];

#Connect to manager interface .
my $manager_sock = new IO::Socket::INET
        (PeerPort=>5038,
        Proto=>'tcp',
        PeerAddr=>'192.168.0.100');
# Login.
if($manager_sock->send( "Action: Login\r\nUsername: admin\r\nSecret: amp111\r\nActionID: 1\r\n\r\n") == 0)

{
print "Failed to send login information\r\n";
exit(1);
}

$manager_sock->send("Action: Originate\r\nChannel: SIP/102\r\nContext: from-internal\r\nExten: $num\r\nPriority: 1\r\n\r\n");
$manager_sock->close();

I can probably make it more robust, but this is how I did it.