Build a low code conversational SMS bot with Azure Communication Services and Azure OpenAI
In our last blog, we walked through the process of building an SMS conversational bot. Today we want to showcase a similar bot, but this time built completely on top of low code connectors for Power Automate. It is incredibly easy and exciting to leverage Azure Communication Services connectors in conjunction with Large Language Models (LLM) like ChatGPT to build a conversation bot. For this blog, we will be building Anton, a personal trainer bot for Contoso Gym. See the preview:
To follow along you will need:
- An Azure account with an active subscription. Create an account for free.
- Enable Event Grid resource provided on your subscription. See instructions.
- An active Communication Services resource and connection string. Create a Communication Services resource.
- An SMS-enabled telephone number. Get a phone number.
- Azure OpenAI resource. See instructions.
- Azure OpenAI deployed model. See instructions.
- Power Automate account. Azure Communication Services connectors require a plan that supports premium connectors.
This application will leverage Azure Event Grid to listen for incoming text messages to Azure Communication Services number, and an Azure Function to process the event and respond with an Azure OpenAI generated response.
We will start by configuring an Event Grid trigger for your Power Automate flow. This trigger will automatically connect to your existing Azure subscription and to the Azure Communication Services resource to configure your event subscription.
To keep the data organized, you will add a Parse JSON connector to help us parse the event. The event schema follows this structure:
Schema (click to see)
Add that schema to the Parse JSON connector and add the event body as the content.
Next, we must add a call to Azure OpenAI to ask the model to generate a response. We will use REST APIs to POST a request with our prompt. For the prompt, we will use a combination of the message sent by the user and a pre-designed text. In this example, we want the GPT-3 model to act like Anton, a personal trainer at Contoso Gym. We added some sample quotes from which the model can draw inspiration. These quotes help guide the model’s response and provide a more intuitive and conversational flow for the users. See the completed prompt below:
To keep the flow organized, we will add a compose connector for our prompt so we can easily reference it later.
To communicate with the Azure OpenAI service, we will use POST request inside of an HTTP connector. In return, we will receive a text generated by the Azure OpenAI model. To configure the HTTP connector, you will need the URI to your Azure OpenAI resource. You will also need the `api-key` for your Azure OpenAI resource.
Using the compose output for our prompt, we will concatenate together the prompt, the message the user sent through SMS, and a stop trigger for the Open AI model to stop generating text:
Once we have the HTTP connector d, we will use a Parse JSON connector to process the response from Azure Open AI. The expected schema from Azure Open AI takes the following format:
Schema (click to see)
We will configure it to use the body of the http request as the content the schema above.
Finally, we will configure our SMS connector for Azure Communication Services to respond with the new response generated by Azure OpenAI. You will need a connection string for your Azure Communication Services resource to initialize the SMS connector.
Now that everything is connected, test the flow by sending an SMS from your phone to the phone number you acquired through the Azure Communication Services resource.
Congratulations! using Power Automate. Azure Communication Services provides out of the box connectors for SMS, Email and Chat. Whether it is having Anton, the personal trainer bot talk to your customers or having a real person interact with them, Azure Communication Services can help. To learn more about other resources that Azure Communication Services offers see the links below:
- Overview of Azure Communication Services.
- SMS Connector
- Email Connector
- Chat Connector
- Identity Connector
- Want to learn how to do this in code, checkout out last blog post.
Published on:
Learn moreRelated posts
Record Scanner for vinyl collectors cuts costs with Azure Cosmos DB vector search
by Artur Drozdz, Founder of Record Scanner (recordscanner.com) If you’re like me, there’s at least one room in your home with an entire cabine...
🚀 Introducing the New VS Code Extension for Azure Cosmos DB
We’re excited to share that the Azure Databases extension for Visual Studio Code is now officially rebranded as the Azure Cosmos DB extension!...
AI-based T-SQL Refactoring: an automatic intelligent code optimization with Azure OpenAI
This article presents an AI-powered approach to automating SQL Server code analysis and refactoring. The system intelligently identifies ineff...
Azure Boards integration with GitHub Copilot (Private Preview)
Several months ago, GitHub introduced the public preview of its Copilot coding agent, a powerful new capability that allows you to assign GitH...
What is Azure Key Vault and How It Secures Microsoft Dynamics 365 CRM Systems?
Azure Key Vault is a service by Microsoft Azure that helps securely store and manage sensitive information such as API keys, connection string...
Azure AI Foundry Model In Copilot Studio Custom Prompts
Any custom model created in Azure AI Foundry can be used in Copilot Studio. This ... The post Azure AI Foundry Model In Copilot Studio Custom ...
Running Teams PowerShell Cmdlets in Azure Automation
This article describes the prerequisites and how to run cmdlets from the Teams PowerShell module in Azure Automation runbooks. We also conside...