# Using voice and fax: faxback

Uses voice and fax functions to receive a call, play a prompt menu, and respond to input by sending a fax to the caller. It can receive input from a live caller, or from the simulated caller provided by the caller demonstration program.

#### Usage

faxback [options]

options are:

Option | Description | Default
--- | --- | ---
-b n | Specifies the AG or CG board number n. | 0
-q | Specifies that the board is a QX 2000 board. | AG/CG board
-s n:m | Specifies the stream and timeslot. | 0:0
-r resolution | Specifies the resolution (low, high, or superhigh). | low
-e encoding | Specifies the encoding (1D, 2D, or MMR). | 1D
-c mode | Specifies the conversion mode: y = yes (NFX_OTF_ALWAYS) m = maybe (NFX_OTF_ONLY_IF_FAIL) n = no (NFX_OTF_NEVER) | m
-p protocol | Specifies the protocol (TCP name). | nocc
-E | Specifies that ECM mode is used when encoding is 1D or 2D. | Do not use ECM.
-v | Specifies verbose reporting of event information. | Non-verbose reporting.

#### Description

faxback demonstrates how to use voice, DTMF detection, and fax functions during a single telephone call. It uses API functions from NaturalFax, Natural Access, and the ADI service. faxback plays a fixed prompt menu to the caller, allows the caller to select a document, and faxes the document back to the caller.

faxback can be used interactively by calling it from a fax machine. It can also be used in conjunction with caller, a NaturalFax automated testing demonstration program.

### Running faxback on its own

faxback performs the following tasks:

Task | Description
1 | faxback first initializes the Natural Access environment and then opens the ADI service on a context associated with the specified board, stream, and timeslot.
2 | When faxback receives a call, it plays a voice menu prompt requesting that the caller enter DTMF tones to select a document.
3 | faxback initializes a document queue and uses DTMF detection to determine which documents the caller selected.
4 | faxback enqueues the documents, sets transmit parameters, and transmits the requested documents.
5 | faxback monitors all events until it receives the NFXEVN_SESSION_DONE event. It takes appropriate actions if the call is disconnected or if a board error occurs.
6 | After the fax is transmitted, the document queue is destroyed and faxback waits for the next incoming call.

faxback runs in an infinite loop. Press Ctrl+C to terminate the program.

### Running faxback and caller together

If faxback and caller are used together, the programs synchronize with each other using DTMF tones:

Task | Description
1 | faxback initializes Natural Access and opens the ADI service on a context associated with the specified board, stream, and timeslot.
2 | It places the call and sets up detection of the DTMF tone that signals the end of the prompt menu.
3 | When it receives this tone, it generates the DTMF tone that corresponds to a request for a document catalog.
4 | caller then creates a document queue, enqueues temporary files, sets receive parameters, and receives the document when faxback transmits it.
5 | caller monitors events until it receives the NFXEVN_SESSION_DONE event. It takes appropriate actions if the call is disconnected or if a board error occurs.
6 | After the fax has been received, the document queue is destroyed, and caller places another call.

caller runs in an infinite loop. Press Ctrl+C to terminate the program.