4

I am about to make some email to fax gateway --- some python program will make Asterisk call files and put them into some queue (files or db based).

Then another program should take "call tasks" from queue and "feed" them to asterisk (honoring some configured limit, because of res_fax_digium will drop over-limited tasks).

Next, let's suppose, everything is great and asterisk successfully sent some fax document. What could be a way to get the status of this operation?

If logfiles parsing is the best, I would, probably, assign some special accountcode (I can play with this field, probably) to drop CDRs into separate files, too.

Please, which other ways I should evaluate?

masegaloeh
  • 17,978
  • 9
  • 56
  • 104
brownian
  • 291
  • 3
  • 13

1 Answers1

3

So, I dropped this approach and will go another way --- AMI, Asterisk Management Interface API.

In a couple of words.

Having created dialplan like this one:

[01-sendfax]
exten => _X.,1,NoOp()
     same => n,SendFax(${faxfile},f)

I can originate calls with (using pyst):

res = mgr.originate(
    'SIP/m2000/1234567',
    '1234567',
    context='01-sendfax',
    priority='1',
    caller_id='7654321',
    async=True,
    variables={
        'TRUNK': 'SIP/m2000',
        'faxfile': '/tmp/file.tiff',
    }
)

And having set debug = on in manager.conf, I can listen to needed events:

# will catch a status of `originate` call
# (this does not require `debug = on` in `manager.conf`):
mgr.register_event('OriginateResponse', handle_response)

# will catch `SendFax` application's result:
mgr.register_event('FaxStatus', handle_response)

So, res_fax_digium fires FaxStatus event after SendFax is complete.

brownian
  • 291
  • 3
  • 13