Quickstart: Handle Advanced Messaging events

Azure Communication Services now enables you to send and receive WhatsApp messages using the Advanced Messaging SDK. Get started with setting up Event Grid events for receiving WhatsApp messages send/receive status reports. Completing this quickstart incurs a small cost of a few USD cents or less in your Azure account.

Prerequisites

About Event Grid

Event Grid is a cloud-based eventing service. In this article, you learn how to subscribe to 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 send the events to a web app that collects and displays the messages.

Set up Event Grid Viewer

The Event Grid Viewer is a sample site that allows you to view incoming events from Event Grid.

  1. Go to this Link Azure Event Grid Viewer - Code Samples | Microsoft Learn. Deploy the Event Grid Viewer sample by clicking Deploy to Azure.

    Screenshot that shows the Event Grid Viewer Sample Page with Deploy To Azure option.

  2. After clicking the Deploy to Azure, fill in the required fields. Because the site name creates a DNS entry, it needs to be globally unique. We recommended that you include your alias in the name for this step. While this quickstart doesn't require any special setup for this step, here are suggestions for filling out the deployment details:

  • Subscription - Select the subscription that contains your Azure Communication Services resource. This specific subscription isn't required, but it will make it easier to clean up after you're done with the quickstart.

  • Resource Group - Select the resource group that contains your Azure Communication Services resource. This specific resource group isn't required, but it will make it easier to clean up after you're done with the quickstart.

  • Region - Select the resource group that contains your Azure Communication Services resource. This specific region isn't required, but is recommended.

  • Site Name - Create a name that is globally unique. This site name is used to create a domain to connect to your Event Grid Viewer.

  • Hosting Plan Name - Create any name to identify your hosting plan.

  • Sku - The sku F1 can be used for development and testing purposes. If you encounter validation errors creating your Event Grid Viewer that say there's no more capacity for the F1 plan, try selecting a different region. For more information about skus, see App Service pricing

    Screenshot that shows Custom deployment of Events Viewer web app and properties you need to provide to successfully deploy.

  1. Then select Review + Create.

  2. After the deployment completes, select on the App Service resource to open it.

    Screenshot that shows Events Viewer web app.

  3. On the resource overview page, select on the copy button next to the Default Domain property.

    Screenshot that shows URL of Events Viewer web app.

  4. The URL for the Event Grid Viewer is the Site Name you used to create the deployment with the path /api/update appended. For example: "https://{{site-name}}.azurewebsites.net/api/updates". You'll need it in the next step and during the creation of the demo app.

Subscribe to Advanced Messaging events

  1. Open your Communication Services resource in the Azure portal, navigate to the Events option in left panel, and select +Event Subscription.

    Screenshot that shows Azure Communication Services Events subscription option and allows you to subscribe to Advanced Messaging events.

  2. Fill in the details for the new event subscription.

    • Subscription name.

    • System topic name - Enter a unique name, unless this name is already prefilled with a topic from your subscription.

    • Event types - Select the two Advanced messaging events from the list.

      Screenshot that shows create event subscription properties.

    • Optional: Select the AdvancedMessageAnalysisCompleted event, currently in public preview, to receive Message Analysis events. Instruction on how to enable Message Analysis can be found at Enable Message Analysis with Azure OpenAI

      Important

      This feature of Azure Communication Services is currently in preview.

      Preview APIs and SDKs are provided without a service-level agreement. We recommend that you don't use them for production workloads. Some features might not be supported, or they might have constrained capabilities.

      For more information, review Supplemental Terms of Use for Microsoft Azure Previews.

      Screenshot that shows how to create Message Analysis event subscription properties.

    • For endpoint type, select "Webhook" and enter the URL for the Event Grid Viewer we created in the Setup Event Grid Viewer step with the path /api/updates appended. For example: https://{{site-name}}.azurewebsites.net/api/updates.

      Screenshot that shows how to update webhook url of event subscription to receive events.

    • Select Create.

  3. Navigate back to the Events option in left panel of your Azure Communication Services resource. Notice the new event subscription with Advanced Messaging events.

    Screenshot that shows two Advanced messaging events subscribed.

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.

Next steps

Advance to the next article to learn how to use Advanced Messaging SDK for WhatsApp messaging.