Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
941 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
How to play IVR(Inbound call) in my scenario. I have a PSTN Number when customer call this Number I Received Incoming call Event via Webhook after this Event received I want to play the IVR to the caller(customer), Could you provide me a solution to play IVR in this Scenario
Below is a quick overview I put together:
To play an IVR (Interactive Voice Response) message to a caller using Azure Communication Services (ACS) after receiving an inbound PSTN call, you can follow these general steps:
Here's a basic example in C# to illustrate how you might handle this:
using Azure.Communication.CallingServer;
using Azure.Messaging.EventGrid;
using System;
using System.Threading.Tasks;
public class IVRService
{
private readonly string connectionString = "<YOUR_ACS_CONNECTION_STRING>";
private readonly CallAutomationClient callAutomationClient;
public IVRService()
{
callAutomationClient = new CallAutomationClient(connectionString);
}
public async Task HandleIncomingCall(EventGridEvent eventGridEvent)
{
// Parse the incoming call event
var incomingCallEvent = eventGridEvent.Data.ToObjectFromJson<IncomingCallEventData>();
// Extract the call ID and caller ID
var callId = incomingCallEvent.CallId;
// Play IVR message
await PlayIVRMessage(callId);
}
private async Task PlayIVRMessage(string callId)
{
var audioUrl = new Uri("https://<YOUR_AUDIO_FILE_URL>.wav");
var playSource = new FileSource(audioUrl);
// Play the audio to the caller
await callAutomationClient.GetCallConnection(callId).PlayAsync(playSource);
}
}
Additional thoughts: