|
| 1 | +--- |
| 2 | +title: Quickstart - Send chat message in Power Automate with Azure Communication Services |
| 3 | +titleSuffix: An Azure Communication Services quickstart |
| 4 | +description: In this quickstart, learn how to send a chat message in Azure Logic Apps workflows by using the Azure Communication Services Chat connector. |
| 5 | +author: sanchezjuan |
| 6 | +manager: chpalm |
| 7 | +services: azure-communication-services |
| 8 | +ms.author: sanchezjuan |
| 9 | +ms.date: 07/20/2022 |
| 10 | +ms.topic: quickstart |
| 11 | +ms.service: azure-communication-services |
| 12 | +ms.custom: mode-other |
| 13 | +--- |
| 14 | + |
| 15 | +# Quickstart: Send chat message in Power Automate with Azure Communication Services |
| 16 | + |
| 17 | +You can create automated workflows that can send chat messages using the Azure Communication Services Chat connector. This quickstart will show how to create a chat, add a participant, send a message and list messages into an existing workflow. |
| 18 | + |
| 19 | +## Prerequisites |
| 20 | + |
| 21 | +- An Azure account with an active subscription, or [create an Azure account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). |
| 22 | + |
| 23 | +- An active Azure Communication Services resource, or [create a Communication Services resource](../create-communication-resource.md). |
| 24 | + |
| 25 | +- An active Logic Apps resource (logic app), or [create a blank logic app but with the trigger that you want to use](../../../logic-apps/quickstart-create-first-logic-app-workflow.md). Currently, the Azure Communication Services Chat connector provides only actions, so your logic app requires a trigger, at minimum. |
| 26 | + |
| 27 | + |
| 28 | +## Create user |
| 29 | + |
| 30 | +Add a new step in your workflow by using the Azure Communication Services Identity connector, follow these steps in Power Automate with your Power Automate flow open in edit mode. |
| 31 | + |
| 32 | +1. On the designer, under the step where you want to add the new action, select New step. Alternatively, to add the new action between steps, move your pointer over the arrow between those steps, select the plus sign (+), and select Add an action. |
| 33 | + |
| 34 | +1. In the Choose an operation search box, enter Communication Services Identity. From the actions list, select Create a user. |
| 35 | + |
| 36 | + :::image type="content" source="./media/logic-app/azure-communications-services-connector-create-user.png" alt-text="Screenshot that shows the Azure Communication Services Identity connector Create user action."::: |
| 37 | + |
| 38 | +1. Provide the Connection String. This can be found in [Microsoft Azure](https://portal.azure.com/), within your Azure Communication Service Resource, on the Keys option from the left menu > Connection String |
| 39 | + |
| 40 | + :::image type="content" source="./media/logic-app/azure-portal-connection-string.png" alt-text="Screenshot that shows the Keys page within an Azure Communication Services Resource." lightbox="./media/logic-app/azure-portal-connection-string.png"::: |
| 41 | + |
| 42 | +1. Provide a Connection Name |
| 43 | + |
| 44 | +1. Click “Show advanced options” and select the Token Scope the action will also output an access token and its expiration time with the specified scope. |
| 45 | + |
| 46 | + This action will output a User ID, which is a Communication Services user identity. |
| 47 | + Additionally, if you click “Show advanced options” and select the Token Scope the action will also output an access token and its expiration time with the specified scope. |
| 48 | + |
| 49 | + :::image type="content" source="./media/logic-app/azure-communications-services-connector-create-user-action.png" alt-text="Screenshot that shows the Azure Communication Services Identity connector Create user action options."::: |
| 50 | + |
| 51 | +1. Select “chat” |
| 52 | + |
| 53 | + :::image type="content" source="./media/logic-app/azure-communications-services-connector-create-user-action-advanced.png" alt-text="Screenshot that shows the Azure Communication Services Chat connector advanced options."::: |
| 54 | + |
| 55 | +1. Click Create. This will output the User ID and an Access Token. |
| 56 | + |
| 57 | +## Create a chat thread |
| 58 | + |
| 59 | +1. Add a new action |
| 60 | + |
| 61 | +1. In the Choose an operation search box, enter Communication Services Chat. From the actions list, select Create chat thread. |
| 62 | + |
| 63 | + :::image type="content" source="./media/logic-app/azure-communications-services-connector-create-chat-thread.png" alt-text="Screenshot that shows the Azure Communication Services Chat connector Create a chat thread action."::: |
| 64 | + |
| 65 | +1. Provide the Azure Communication Services endpoint URL. This can be found in [Microsoft Azure](https://portal.azure.com/), within your Azure Communication Service Resource, on the Keys option from the left menu > Endpoint. |
| 66 | + |
| 67 | +1. Provide a Connection Name |
| 68 | + |
| 69 | +1. Select the Access Token from the previous step, add a Chat thread topic description. Additionally, add the created user and add a Name for the participant. |
| 70 | + |
| 71 | + :::image type="content" source="./media/logic-app/azure-communications-services-connector-create-chat-thread-input.png" alt-text="Screenshot that shows the Azure Communication Services Chat connector Create chat thread action input fields."::: |
| 72 | + |
| 73 | +## Send a message |
| 74 | + |
| 75 | +1. Add a new action |
| 76 | + |
| 77 | +1. In the Choose an operation search box, enter Communication Services Chat. From the actions list, select Send a Chat message to chat thread. |
| 78 | + |
| 79 | + :::image type="content" source="./media/logic-app/azure-communications-services-connector-send-chat-message.png" alt-text="Screenshot that shows the Azure Communication Services Chat connector Send chat message action."::: |
| 80 | + |
| 81 | +1. Provide the Access Token, Thread ID, Content, and Name information as shown below. |
| 82 | + |
| 83 | + :::image type="content" source="./media/logic-app/azure-communications-services-connector-send-chat-message-input.png" alt-text="Screenshot that shows the Azure Communication Services Chat connector Send chat message action input fields."::: |
| 84 | + |
| 85 | +## List chat thread messages |
| 86 | + |
| 87 | +To verify you have correctly sent a message, we will add one more action to list the chat thread messages. |
| 88 | +1. Add a new action |
| 89 | + |
| 90 | +1. In the Choose an operation search box, enter Communication Services Chat. From the actions list, select List chat thread messages. |
| 91 | + |
| 92 | + :::image type="content" source="./media/logic-app/azure-communications-services-connector-list-chat-messages.png" alt-text="Screenshot that shows the Azure Communication Services Chat connector List chat messages action."::: |
| 93 | + |
| 94 | +1. Provide the Access token and Thread ID as follows |
| 95 | + |
| 96 | + :::image type="content" source="./media/logic-app/azure-communications-services-connector-list-chat-messages-input.png" alt-text="Screenshot that shows the Azure Communication Services Chat connector Send chat message action input."::: |
| 97 | + |
| 98 | +## Test your logic app |
| 99 | + |
| 100 | +To manually start your workflow, on the designer toolbar, select **Run**. The workflow should create a user, issue an access token for that user, then remove it and delete the user. For more information, review [how to run your workflow](../../../logic-apps/quickstart-create-first-logic-app-workflow.md#run-workflow). |
| 101 | + |
| 102 | +Now click on the List chat thread messages and check the output, the message sent will be in the action outputs. |
| 103 | + |
| 104 | +:::image type="content" source="./media/logic-app/azure-communications-services-connector-list-chat-messages-output.png" alt-text="Screenshot that shows the Azure Communication Services Chat connector Send chat message action output."::: |
| 105 | + |
| 106 | +## Clean up resources |
| 107 | + |
| 108 | +To remove a Communication Services subscription, delete the Communication Services resource or resource group. Deleting the resource group also deletes any other resources in that group. For more information, review [how to clean up Communication Services resources](../create-communication-resource.md#clean-up-resources). |
| 109 | + |
| 110 | +To clean up your logic app workflow and related resources, review [how to clean up Logic Apps resources](../../../logic-apps/quickstart-create-first-logic-app-workflow.md#clean-up-resources). |
| 111 | + |
| 112 | +## Next steps |
| 113 | + |
| 114 | +In this quickstart, you learned how to create a user, create a chat thread and send a message using the Azure Communication Services Identity and Azure Communication Services Chat connectors. To learn more check the [Azure Communication Services Chat Connector](/connectors/acschat/) documentation. |
| 115 | + |
| 116 | +To learn more about access tokens check [Create and Manage Azure Communication Services users and access tokens](../chat/logic-app.md). |
| 117 | + |
| 118 | +To learn more about how to send an email check [Send email message in Power Automate with Azure Communication Services](../email/logic-app.md). |
| 119 | + |
0 commit comments