Quickstart: Handle voice and video calling events

Important

Functionality described in this document is currently in public preview. This preview version is provided without a service-level agreement, and it's not recommended for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.

Get started with Azure Communication Services by using Azure Event Grid to handle Communication Services voice and video calling events.

About Azure Event Grid

Azure Event Grid is a cloud-based eventing service. In this article, you'll learn how to subscribe to events for communication service events, and trigger an event to view the result. Typically, you send events to an endpoint that processes the event data and takes actions. In this article, we'll send the events to a web app that collects and displays the messages.

Prerequisites

Setting up

Enable Event Grid resource provider

If you haven't previously used Event Grid in your Azure subscription, you may need to register the Event Grid resource provider following the steps below:

In the Azure portal:

  1. Select Subscriptions on the left menu.
  2. Select the subscription you're using for Event Grid.
  3. On the left menu, under Settings, select Resource providers.
  4. Find Microsoft.EventGrid.
  5. If not registered, select Register.

It may take a moment for the registration to finish. Select Refresh to update the status. When Status is Registered, you're ready to continue.

Event Grid Viewer deployment

For this quickstart, we will use the Azure Event Grid Viewer Sample to view events in near-real time. This will provide the user with the experience of a real-time feed. In addition, the payload of each event should be available for inspection as well.

Subscribe to voice and video calling events using web hooks

In the portal, navigate to your Azure Communication Services Resource that you created. Inside the Communication Service resource, select Events from the left menu of the Communication Services page.

Screenshot showing selecting the event subscription button within a resource's events page.

Press Add Event Subscription to enter the creation wizard.

On the Create Event Subscription page, Enter a name for the event subscription.

You can subscribe to specific events, to tell Event Grid which of the voice and video events you want to subscribe to, and where to send the events. Select the events you'd like to subscribe to from the dropdown menu. For voice and video calling you'll have the option to choose Call Started, Call Ended, Call Participant added and Call Participant Removed.

If you're prompted to provide a System Topic Name, feel free to provide a unique string. This field has no impact on your experience and is used for internal telemetry purposes.

Check out the full list of events supported by Azure Communication Services.

Screenshot showing the calling event types being selected.

Select Web Hook for Endpoint type.

Screenshot showing the Endpoint Type field being set to Web Hook.

For Endpoint, click Select an endpoint, and enter the URL of your web app.

In this case, we will use the URL from the Azure Event Grid Viewer Sample we set up earlier in the quickstart. The URL for the sample will be in the format: https://{{site-name}}.azurewebsites.net/api/updates

Then select Confirm Selection.

Screenshot showing confirming a Web Hook Endpoint.

Viewing voice and video calling events

Triggering voice and video calling events

To view event triggers, we must first generate the events.

  • Call Started events are generated when a Azure Communication Services voice and video call is started. To trigger this event, just start a call attached to your Communication Services resource.
  • Call Ended events are generated when a Azure Communication Services voice and video call is ended. To trigger this event, just end a call attached to your Communication Services resource.
  • Call Participant Added events are generated when a participant is added to an Azure Communication Services voice and video call. To trigger this event, add a participant to an Azure Communication Services voice and video call attached to your Communication Services resource.
  • Call Participant Removed events are generated when a participant is removed from an Azure Communication Services voice and video call. To trigger this event, remove a participant from an Azure Communication Services voice and video call attached to your Communication Services resource.

Check out the full list of events supported by Azure Communication Services.

Receiving voice and video calling events

Once you complete either action above you will notice that voice and video calling events are sent to your endpoint. These events will show up in the Azure Event Grid Viewer Sample we set up at the beginning. You can press the eye icon next to the event to see the entire payload.

Learn more about the event schemas and other eventing concepts.

Clean up resources

If you want to clean up and remove a Communication Services subscription, you can delete the resource or resource group. Deleting the resource group also deletes any other resources associated with it. Learn more about cleaning up resources.

You may also want to: