API Reference

View as Markdown

TelcoflowClientConfig

The public 0.24.0 docs present TelcoflowClientConfig through factory helpers rather than direct constructor examples.

Factory Helpers

HelperUseParameters
TelcoflowClientConfig.sandbox(...)SANDBOX mode with API key authenticationapi_key, connector_uuid, sample_rate
TelcoflowClientConfig.production(...)PROD mode with mTLS authenticationcert_path, key_path, sample_rate

Examples

1sandbox_config = TelcoflowClientConfig.sandbox(
2 api_key="YOUR_API_KEY",
3 connector_uuid="YOUR_CONNECTOR_UUID",
4 sample_rate=24000,
5)
6
7production_config = TelcoflowClientConfig.production(
8 cert_path="/etc/certs/client.pem",
9 key_path="/etc/certs/client.key",
10 sample_rate=24000,
11)

TelcoflowClient

Main client class for managing the control connection and dispatching call events.

Methods

MethodDescription
run_forever()Run until the client is closed. Use this inside async with TelcoflowClient(config) as client: for long-lived apps
connect()Explicitly open the control connection
disconnect()Explicitly close the control connection
on(event)Decorator for client-level handlers such as events.INCOMING_CALL or ClientEvent.INCOMING_CALL
get_call(call_id)Get an active call by ID

Context Manager

1async with TelcoflowClient(config) as client:
2 @client.on(events.INCOMING_CALL)
3 async def on_call(call):
4 await call.answer()
5
6 await client.run_forever()

ActiveCall

Represents a call session with an attached media connection.

Methods

MethodParametersDescription
answer()Answer the incoming call
connect()ring_time_seconds=60Initiate a 3-way conference between the caller, callee, and agent
whisper()Route the agent’s audio to the callee only
barge()Route the agent’s audio to both caller and callee
spy()Put the agent in listen-only mode
disconnect()End the call for all parties
close()Close the call and release resources. After connect(), the agent leaves while caller and callee stay connected. After answer() without connect(), the call ends for both agent and caller
force_disconnect()Forcefully tear down the call from the client side
send_audio()audio_data: bytesQueue raw PCM audio for playback
clear_send_audio_buffer()Clear all queued outgoing audio
get_send_audio_buffer_size()Return the current queued buffer size
audio_stream()Async iterator for incoming audio chunks
on(event)handlerDecorator for call-level event handlers such as events.CALL_TERMINATED or CallEvent.CALL_TERMINATED

Properties

PropertyTypeDescription
call_idstrUnique call identifier
caller_numberstrCaller phone number
callee_numberstrCallee phone number
directionstrCall direction, such as "MT"

Events

All string event constants are available from telcoflow_sdk.events:

1import telcoflow_sdk.events as events

The public 0.24.0 package docs also describe ClientEvent and CallEvent enums as type-safe alternatives to these string constants.

EventLevelDescription
events.INCOMING_CALLClientA new call has arrived
events.CALL_TERMINATEDCallThe call has ended
events.CALL_ANSWEREDCallThe call was successfully answered
events.CALL_CONNECTEDCallThe connect operation succeeded
events.CALL_CONNECT_FAILEDCallThe connect operation failed
events.CALL_ANSWER_FAILEDCallThe answer attempt failed

Next Steps