-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
Package Information
- Package Name:
azure-communication-messages - Package Version: 1.2.0b1 | 1.1.0
- Operating System: macOS (darwin-arm64)
- Python Version: 3.11
Describe the bug
When sending audio notifications via AudioNotificationContent through Azure Communication Services to WhatsApp recipients, the messages are never received by the recipient. However, both ImageNotificationContent and TextNotificationContent work without any issues using the same channel registration and recipients.
The C# SDK successfully sends audio notifications with the same media URIs and configuration, suggesting this is a Python SDK-specific issue.
To Reproduce
Steps to reproduce the behavior:
- Initialize the
NotificationMessagesClientwith a valid connection string:
from azure.communication.messages.aio import NotificationMessagesClient
from azure.communication.messages.models import AudioNotificationContent
connection_string = ""
client = NotificationMessagesClient.from_connection_string(connection_string)- Create an
AudioNotificationContentobject with a valid media URI:
channel_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
recipients = ["1234567890"]
media_url = "<url to public mp3 file>"
audio_notification = AudioNotificationContent(
channel_registration_id=channel_id,
to=recipients,
media_uri=media_url
)- Send the notification:
await client.send(audio_notification)Returns a receipt with messageId
- Check WhatsApp on the recipient's device - no message is received
Expected behavior
The audio notification should be delivered to the WhatsApp recipient, similar to how ImageNotificationContent and TextNotificationContent are successfully delivered.
When using the same configuration with the C# SDK, audio notifications are delivered successfully, indicating the issue is specific to the Python SDK implementation.
Working alternatives (for comparison)
These notification types work correctly with the same configuration:
Text (Works):
text_notification = TextNotificationContent(
channel_registration_id=channel_id,
to=recipients,
content="Hello from Azure Communication Services via WhatsApp!"
)
await client.send(text_notification) # ✅ Received successfullyImage (Works):
image_notification = ImageNotificationContent(
channel_registration_id=channel_id,
to=recipients,
media_uri="https://aka.ms/acsicon1",
content="Check out this image!"
)
await client.send(image_notification) # ✅ Received successfullyAudio (Does NOT work):
audio_notification = AudioNotificationContent(
channel_registration_id=channel_id,
to=recipients,
media_uri=media_url
)
await client.send(audio_notification) # ❌ Not receivedWorkaround attempted
Tried using the generic NotificationContent with explicit kind parameter:
general_notification = NotificationContent(
{
"channelRegistrationId": channel_id,
"to": recipients,
"kind": "audio",
"mediaUri": media_url
}
)
await client.send(general_notification) # Result: Similar resultAdditional context
- Multiple media URIs have been tested (both Azure Blob Storage URLs with SAS tokens and public URLs)
- All media URIs are accessible and return valid audio content when accessed directly
- The same media URIs work when used with the C# SDK
- No exceptions or errors are raised by the Python SDK - the
send()method completes successfully - The issue persists across different audio formats (MP3, OGG)
- Channel registration ID and recipient numbers are confirmed valid (they work for text and image)
- Connection string and authentication are working (confirmed by successful text/image delivery)
Investigation needed
- Compare the HTTP request payloads between Python and C# SDKs when sending audio notifications
- Verify if there's a difference in how
AudioNotificationContentserializes the request body - Check if there are any missing or incorrectly set properties specific to audio content in the Python implementation
- Validate the
kindfield value being sent in the Python SDK request
Environment
- Azure Communication Services: Advanced Messaging (WhatsApp)
- Function App: Azure Functions (Flex Consumption, Python 3.11)
- Storage: Azure Blob Storage with SAS token authentication
- Audio files: MP3 format, stored in Azure Blob Storage with proper MIME types