Kaido Jarvemets - Logo

Unleashing the Power of Azure Communication Services

Introduction

Azure Communication Services (ACS) is a powerful suite of communication tools offered by Microsoft Azure. It provides developers with the ability to incorporate a variety of communication methods into their applications, including SMS, voice and video calling, chat, and email. These services are designed to be highly scalable, reliable, and secure, making them suitable for applications of all sizes and complexities.

One of the key strengths of ACS is its seamless integration with other Azure services. This integration allows developers to leverage the full power of the Azure ecosystem, enhancing the capabilities of their applications. For instance, ACS can be combined with Azure Functions to automate communication tasks, or with Azure Logic Apps to create complex communication workflows. This interoperability not only simplifies the development process but also opens up a world of possibilities for creating innovative and engaging communication experiences.

Core Concepts

SMS

Short Message Service (SMS) is a widely used communication method that allows the sending of text messages between mobile devices. Azure Communication Services (ACS) extends this capability to applications, enabling them to send SMS messages to users worldwide. This service can be used for a variety of purposes, such as sending notifications, alerts, reminders, or one-time passwords.

Using the SMS service in ACS is straightforward. Developers can use the ACS SMS client library, which provides methods for sending SMS messages. These methods require the phone number of the recipient and the message content. Additionally, developers can specify whether the message should be sent as a single SMS or as multiple messages if it exceeds the maximum length of a single SMS.

Handling SMS events is another crucial aspect of the SMS service. ACS provides a mechanism for receiving delivery reports for the SMS messages sent. These reports provide information about the delivery status of the message, such as whether it was delivered, failed, or is still in progress. To handle these events, developers need to set up a webhook that ACS can call when a delivery report is available. The webhook should be designed to receive the delivery report, process it, and take any necessary actions, such as logging the delivery status or triggering other processes based on the status. This feature allows applications to track the delivery of SMS messages and respond appropriately to any issues that may occur.

Voice and Video Calling

Azure Communication Services (ACS) offers robust capabilities for integrating voice and video calling into applications through its Calling SDK. This SDK provides a comprehensive set of features that enable rich, high-quality, real-time communication experiences. These features include one-to-one and group calls, video conferencing, screen sharing, and call recording, among others. The SDK also supports various audio codecs and video codecs to ensure optimal call quality.

Implementing voice and video calling with the Calling SDK involves several steps. First, developers need to initialize the CallClient object, which serves as the main entry point for calling operations. Next, they can use the CallAgent object, obtained from the CallClient, to start, answer, or reject calls. For video calling, developers can use the VideoStream object to manage the video stream from the local or remote camera. Additionally, the SDK provides events that developers can handle to respond to changes in the call state, such as when a new participant joins the call or when the call ends.

Telephony

Telephony in Azure Communication Services (ACS) refers to the set of services that enable voice communication over the internet. These services leverage Voice over Internet Protocol (VoIP) technology to transmit voice data in packets over the internet, rather than through traditional circuit transmissions of the Public Switched Telephone Network (PSTN). This approach allows for more flexible and cost-effective communication solutions.

ACS provides several telephony services, including outbound and inbound calling, call routing, and direct inward dialing. These services can be used to build a variety of communication solutions, from simple voice calling applications to complex interactive voice response (IVR) systems.

To use the telephony services in ACS, developers need to use the Calling SDK, which provides methods for making and receiving calls. For example, to make an outbound call, developers can use the CallAgent.startCall method, providing the target communication identifier and the call options. For inbound calls, developers can handle the CallAgent.incomingCall event to accept or reject incoming calls.

Additionally, ACS supports telephony integration with Microsoft Teams, allowing calls to be made between ACS applications and Teams users. This integration can be achieved using the Teams interoperability feature of the Calling SDK.

Chat

Chat is a core component of Azure Communication Services (ACS), enabling real-time messaging between users. The chat service in ACS is designed to facilitate both one-on-one and group conversations, making it a versatile tool for a variety of applications, from social platforms to customer service solutions. The chat service in ACS is built around the concept of chat threads. A chat thread can be thought of as a conversation between two or more participants. Each thread contains a series of chat messages, which can be sent by any participant in the thread.

To use the chat service, developers first need to create a ChatClient object, which provides methods for creating and managing chat threads. Once a chat thread is created, developers can use the ChatThreadClient object to send and receive messages within the thread. The ChatThreadClient also provides methods for managing participants in the thread, such as adding or removing participants.

In addition to sending and receiving text messages, the chat service also supports sending read receipts and typing indicators, providing a more interactive and engaging chat experience.

Email

Email is a fundamental communication tool, and Azure Communication Services (ACS) provides a robust service for integrating email functionality into applications. The email service in ACS allows applications to send emails to users, supporting a wide range of use cases from notifications to marketing communications.

To use the email service, developers first need to prepare an email communication resource. This involves setting up an email account with a provider supported by ACS and configuring the necessary settings, such as the SMTP server and authentication details.

Once the email communication resource is set up, developers can use the EmailClient object provided by the ACS SDK to send emails. The EmailClient provides methods for sending emails, with support for various email features such as attachments, HTML content, and custom headers. 

Network Traversal

Network traversal in Azure Communication Services (ACS) refers to the techniques used to establish peer-to-peer communication across different networks. This is particularly important for real-time communication scenarios, such as voice and video calling, where direct communication between the peers provides the best performance.

ACS provides a network traversal service that uses the Interactive Connectivity Establishment (ICE) protocol to facilitate this. The service works by providing STUN (Session Traversal Utilities for NAT) and TURN (Traversal Using Relays around NAT) servers that help the peers find each other and establish a direct connection, even if they are behind NATs or firewalls.

To use the network traversal service, developers need to use the CommunicationRelayClient object provided by the ACS SDK. This object provides a method for obtaining relay configuration, which includes the information of the STUN and TURN servers. This configuration can then be used in the setup of the real-time communication session.

Logic Apps Connectors for Azure Communication Services

Logic Apps Connectors for Azure Communication Services (ACS) are designed to work seamlessly with  Azure Communication Services. Azure Logic Apps, a cloud service that helps you schedule, automate, and orchestrate tasks across different applications. These connectors provide a way to integrate ACS capabilities into your workflows, enabling you to automate communication tasks such as sending messages, making calls, or managing communication resources.

ACS Chat Connector for Logic Apps

The ACS Chat Connector for Logic Apps enables you to automate chat operations in your workflows. You can use this connector to send and receive chat messages, manage chat threads, and handle chat events within your Logic Apps, creating rich and automated chat experiences.

Azure Communication Services Chat Logic Apps Actions

  • Add chat thread participants
  • Crate chat thread
  • Get chat thread properties
  • List chat thread messages
  • List chat thread participants
  • List chat threads
  • Remove chat thread participant
  • Sent message to chat thread

ACS Email Connector for Logic Apps

The ACS Email Connector for Logic Apps allows you to automate email operations in your workflows. This connector provides the ability to send emails with various features, such as attachments, HTML content, and custom headers, directly from your Logic Apps.

Azure Communication Services Email Logic Apps Actions

  • Get email message status
  • Send email

ACS Identity Connector for Logic Apps

The ACS Identity Connector for Logic Apps provides a way to manage user identities in ACS directly from your Logic Apps. This connector allows you to create and manage communication users, which are the identities used in ACS for communication purposes.

Azure Communication Services Identity Logic Apps Actions

  • Create a user
  • Delete a user
  • Issue a user access token
  • Revoke user access tokens

Azure Communication Services SMS Connector for Logic Apps

The Azure Communication Services SMS Connector for Logic Apps enables you to automate the process of sending SMS messages in your workflows. This connector provides methods for sending SMS messages to specified phone numbers, directly from your Logic Apps.

Azure Communication Services SMS Logic Apps Actions

  • Send SMS

ACS SMS Events Connector for Logic Apps

The ACS SMS Events Connector for Logic Apps provides a way to handle SMS events in ACS directly from your Logic Apps. This connector allows you to receive delivery reports for the SMS messages sent, providing information about the delivery status of the messages.

Azure Communication Services Events Logic Apps Triggers

  • When an SMS message is received

Azure Communication Services and Azure Event Grid

Azure Communication Services (ACS) also integrates with Azure Event Grid, a fully managed event routing service. This integration allows ACS to deliver real-time event notifications in a reliable, scalable, and secure manner. For instance, you may want to update a database, create a work item, or deliver a push notification whenever an SMS message is received by a phone number associated with your Communication Services resource.

Event Grid uses a publish-subscribe model and has built-in support for Azure services like Azure Functions and Azure Logic Apps. It can also deliver event alerts to non-Azure services using webhooks. ACS emits several event types that you can subscribe to, including chat events, telephony and SMS events, voice and video calling events, presence events, and email events.

This integration with Azure Event Grid further enhances the capabilities of ACS, enabling you to create more dynamic and responsive communication experiences in your applications.

Azure Communication Services and Push Notifications

Azure Communication Services (ACS) also provides support for push notifications, a crucial feature for real-time, mobile communication applications. Push notifications allow your application to notify users of new messages or calls, even when the application is running in the background. ACS integrates with Azure Event Grid and Azure Notification Hubs to enable these push notifications.

The real-time messaging channel created by ACS’s chat and calling SDKs allows signaling messages to be pushed to connected clients efficiently and reliably. However, for mobile applications, this signaling channel remains connected only when the application is active in the foreground. To notify users of incoming calls or chat messages while the application is in the background, ACS uses push notifications.

You can leverage Azure Event Grid to trigger push notifications based on real-time event notifications. Then, Azure Notification Hubs can be used to deliver these push notifications to the user’s mobile device. This integration allows you to create a notification service that delivers mobile push notifications to your users by creating an event grid subscription that triggers an Azure Function or webhook.

This integration with push notifications further enhances the capabilities of ACS, enabling you to create more dynamic and responsive communication experiences in your applications.

Azure Communication Services and Power Apps Integration

Azure Communication Services (ACS) can be seamlessly integrated with Power Apps, a part of Microsoft’s Power Platform that provides a rapid application development environment. This integration allows developers to leverage ACS’s communication capabilities within their Power Apps, enhancing the functionality of these applications.

In a demo showcased in the video, a Power App was created for a gym where users could sign up, choose a trainer, and then receive notifications across various channels. The app used ACS to send these notifications, and also integrated a chat component where users could interact with their chosen trainer. This chat component was a Power Apps Component Framework (PCF) control, which could be easily dragged and dropped onto the Power App.

The Power App also integrated with Azure Event Grid to handle real-time event notifications, and Azure OpenAI to generate responses from the trainer. This demonstrated how ACS can be used in conjunction with other Azure services to create rich, interactive experiences in Power Apps.

Furthermore, the Power App used Power Automate flows to handle various tasks. For instance, one flow was triggered when a user signed up, which created a new record in a table and initiated the notification process. Another flow handled the interaction with the trainer, using the Event Grid connector to listen for incoming messages and the OpenAI service to generate responses.

This integration of ACS with Power Apps demonstrates the potential for creating powerful, communication-enabled applications with low-code solutions. Whether you’re looking to add chat functionality, send notifications, or create interactive experiences, ACS and Power Apps provide the tools you need.

Conclusion

Azure Communication Services (ACS) offers a comprehensive suite of communication tools that can be seamlessly integrated into your applications. From SMS and email services to voice and video calling, chat services, and network traversal capabilities, ACS provides a robust platform for creating rich and engaging communication experiences. Its connectors for Logic Apps further extend its capabilities, allowing you to automate communication tasks and integrate ACS services into your workflows.

The power of ACS lies not just in its individual features, but in how they can be combined and used together. Whether you’re building a simple notification system, a complex customer service application, or anything in between, ACS provides the tools you need to make it happen.

I encourage you to explore the capabilities of ACS and consider how they can enhance your applications. With its wide range of features and its flexibility, ACS offers endless possibilities for innovation in communication.

Sources

Leave a Reply

Contact me

If you’re interested in learning about Unleashing the Power of Azure Communication Services. I can help you understand how this solution can benefit your organization and provide a customized solution tailored to your specific needs.

Table of Contents