SendFax right after ReceiveFax

Hello,

I am trying to do a sendfax right after receivefax, but it seems not working right. The reason is that it seems some carrier (or peer) will fax better then the other. Thus when I try to fax, I would like to:

  1. have Asterisk receive the fax and save it as tif (obviously) using ReceiveFAX
  2. have Asterisk send the fax out by using SendFAX
  3. if the result code is “FAIL” then try another carrier (or peer)

So here is a simple context: (originally)

[InboundFAX]
exten => _.,1,Answer()
exten => _.,n,ReceiveFax(/var/spool/asterisk/fax/testfax.tif)
exten => _.,n,Dial(SIP/carrier/12135551212,60)
exten => _.,n,SendFAX(/var/spool/asterisk/fax/testfax.tif)

but that didn’t work got errors, not sure why, but probably inbound leg was hanging up while asterisk was trying outbound call. so I change to

exten => _.,1,Answer()
exten => _.,n,ReceiveFax(/var/spool/asterisk/fax/testfax.tif)
exten => h,1,Dial(SIP/carrier/12135551212,60)
exten => h,n,SendFAX(/var/spool/asterisk/fax/testfax.tif)

But the script stop excuting at the “dial” command, it probably stop because inbound leg was cut?

So exactly, how can I receive a fax and then sent the .tif file out right away?

thank you!

Sendfax will send to the incoming line, but only if the outgoing call fails. (Dial calls on the outgoing line and doesn’t return whilst that call is up.) In any case, the caller will probably drop the line once the receive is complete, so there will be no channel left to run the dialplan.

The result of using any operation that requires a media or signalling path in the h extension is undefined.

You will probably need to do an originate.

Hello Dave,

I am so glad to see you, always appreciate your prompt reply!

What do you mean by “do an originate”? So doing what I am trying to do will not work in a “single” call?

Also there is a mistake in my code, on the Dial command I need to use “U” option so that on answer, it will just to a macro that execute the “sendFAX” command, or else the way I have it, sendFAX command will never get execute.

But please clarify your “do an originate”. Also, how can asterisk “originate” a call? I guess only by AMI? But I don’t want to do that though…

Or is there any command can keep the asterisk running even when caller disconnect so that it give it the chance to execute the dial command?

so upon further reading and research, like you said, media is “dead” in “h” extension, thus I can not do “dial” command in “h” extension".

So how can I re-originate call within the same context? no way?

And if not, how can I initiate a call from within asterisk context and not have to use AMI or AGI? Or that is not possible?

Have you checked for an Originate application?

Wow, cool, dave, you are great! Ya, didn’t know there is that app, ok, so I am going to try to use the “originate” app within the “h” extension?

thx Dave, you are great!

Ok, thx Dave, I got it working!