The basic usage of the voice phone call API is as follows:
-
The application invokes the Call API to initiate a phone call to a
phone number. The Call API returns immediately with a call ID.
-
The application can then use the call ID to queue tasks that needs
to happen after the user answers her phone. For instance, you can
queue up to make two audio files in a row, and then make a recording
of what the user says. There are a variety of events you can queue
for each call.
-
Each Ringful API call can be associated with a callback url. Ringful
server will report back all events associated with a call ID. For
instance, your application will get notified when the user picks up
the phone, the start / end of audio file playbacks, touch tones the
user generates, and when the user hangs up phone.
The task queue in step #2 is a particularly important concept. Instead
of having your application waiting for call events from the Ringful
server and decide what to do next, you can build a queue of events as a
script, and have Ringful server automatically run through the script for
you. That approach greatly reduces the complexity and latency introduced
by the more traditional callback based programming models.
An example sequence of API calls from the user application would be:
-
/Call/apikey/1234?callee=15125551234&callbackUrl=http://host/call_notify.php&seq=1234&sig=abcd
-- returns CALLID
-
/Play/apikey/1234?callId={$CALLID}&announcement=http://host/welcome_message.wav&seq=1234&sig=abcd
-
/Play/apikey/1234?callId={$CALLID}&announcement=http://host/please_press_1.wav&seq=1234&sig=abcd
-
/WaitForTone/apikey/1234?callId={$CALLID}&tone=1&seq=1234&sig=abcd
-
/Record/apikey/1234?callId={$CALLID}&callbackUrl=http://record_notify.php&seq=1234&sig=abcd
-
/StartToneDetector/apikey/1234?callId={$CALLID}&callbackUrl=http://host//tone_notify.php&seq=1234&sig=abcd
All those calls can be made in a synchronous fashion --
meaning that all those API calls return immediately, and you can call
one API immediately after another in a single client side method.
Ringful server will just queue up the tasks and process them one by one.
The above sequence of API calls first places a phone call to
15125551234; It plays the "welcome" and "please press 1" audio files one
after the other, once the user answers the phone; It then waits for the
user to press the "1" touch tone key; Once the touch tone is detected,
Ringful starts recording whatever the user says, and sends all touch
tones the user generates from now on to the application. All the events
that happen during the call are sent back to the application via
callback URLs.
-
The detected touch tones are POSTed back to the
http://host/tone_notify.php callback URL. The web application
behind the http://host/tone_notify.php callback URL can
make additional Ringful API calls to play more announcements in
response to specific touch tones the user generates.
-
The recorded file URL is sent back to the application via
the http://host/record_notify.php callback URL once the
recording is finished. In this case, the callback is invoked when
the call hangs up.
-
The Call API callback http://host/call_notify.php is
notified when the call is started (i.e., when the user picks up),
when the call is hang up by the user, and when the call is hang up
by the server.
The Call API rings a phone, and establishes a audio connection between
Ringful server and the phone once the user answers the phone. Once the call
is connected, Ringful server moves down the task queue for this call ID to
perform any call tasks required (e.g., Play an audio file, wait for a tone,
or record the user's voice).