Registry / azure / azure-communication-callautomation

azure-communication-callautomation

JSON →
library1.5.0pypypi✓ verified 85d ago

Microsoft Azure Communication Call Automation Client Library for Python, version 1.5.0. Provides APIs to manage and automate voice calls, including answering, connecting, and playing audio. Released monthly with the Azure SDK for Python.

pip install azure-communication-callautomation
INSTALL
IMPORT
SIG · AZURE-COMMUNICATIO
A
azure-communication-callautomation
azurepythonv1.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CallAutomationClient
from azure.communication.callautomation import CallAutomationClient
from azure.communication.callautomation.aio import CallAutomationClient
The synchronous client is in the base module; aio is for async. Ensure correct module for sync vs async.
CallConnection
from azure.communication.callautomation import CallConnection
Standard import for interacting with an active call.
PhoneNumberIdentifier
from azure.communication.callautomation import PhoneNumberIdentifier
from azure.communication.identity import PhoneNumberIdentifier
PhoneNumberIdentifier is re-exported from callautomation; use it directly from callautomation for convenience, but also available from azure.communication.identity.

Initializes CallAutomationClient and answers an incoming call. Requires a connection string or token credential. Callback URL must be HTTPS.

import os from azure.communication.callautomation import CallAutomationClient, AnswerCallOptions, CallInvite, PhoneNumberIdentifier connection_string = os.environ.get('COMMUNICATION_SERVICES_CONNECTION_STRING', '') client = CallAutomationClient.from_connection_string(connection_string) # Example: answer an incoming call incoming_call_context = "incomingCallContextValue" # from event answer_options = AnswerCallOptions(callback_url="https://example.com/callback") result = client.answer_call(incoming_call_context=incoming_call_context, options=answer_options) print(f"Call answered: {result.call_connection_id}")
Debug
Known issues
breakingIn version 1.5.0, the 'AnswerCallOptions' constructor changed: 'callback_url' is now required, and 'operation_context' is deprecated. Use 'options' parameter in answer_call.
fix
Provide callback_url when creating AnswerCallOptions. Do not pass operation_context.
affects: 1.5.0
gotchaThe 'CallAutomationClient' requires a valid 'callback_url' for all operations that receive events (answer, createCall, etc.). The callback URL must be publicly accessible HTTPS endpoint. Localhost will not work.
fix
Use a publicly accessible HTTPS endpoint. For local development, use tools like ngrok.
affects: all
deprecatedUsing 'PlayAudioOptions' with 'loop' parameter is deprecated in 1.5.0. Use 'PlayOptions' with 'loop' parameter instead.
fix
Replace PlayAudioOptions with PlayOptions and set 'loop' accordingly.
affects: >=1.5.0
gotchaThe 'CallConnection' object is only valid for the duration of the call. Once the call is disconnected, any method call on it will raise an exception.
fix
Store call connection id and recreate CallConnection if needed. Listen for call disconnect events to clean up.
affects: all
Errors
Common errors & fixes
AttributeError: 'CallAutomationClient' object has no attribute 'create_call'
Incorrect method name or trying to use sync client with async method. The correct method is 'create_call' on sync client.
fix
Use 'client.create_call(call_invite=...)' for sync. For async, use async client and 'await client.create_call(...)'.
HttpResponseError: (BadRequest) The callback URI is invalid.
The callback URL provided is not HTTPS or not publicly accessible.
fix
Ensure the callback URL starts with 'https://' and is reachable from the internet.
ValueError: The connection string is not a valid Azure Communication Services connection string
The connection string format is incorrect or missing.
fix
Use a connection string from Azure portal, typically 'endpoint=https://...;accesskey=...'. Alternatively, use token credential.
Upgrade
Version history
1.5.0latest on PyPI · released Sep 10, 2025
Audit
Dependencies
azure-communication-identityoptionalRequired for using CommunicationIdentityClient to get tokens for call automation
azure-corerequiredRequired for core Azure SDK functionality
Agent activity
50 hits · last 30 days
node
42
OpenAI (training)
1
Resources
azure-communication-callautomation — pip install azure-communication-callautomation · libregistry