To automate copying messages from Microsoft Teams to a WhatsApp group using Microsoft Power Automate.
Technicians work on night shifts. No engineer work on night shift.
Night shift usually busy.
However, not all technicians are company staff; some are outsourced.
So now the company hopes that outsourced technician staff can see the Teams messages but customer do not want to add in their personal email to teams group. (since customers prefer to use Microsoft Teams over WhatsApp due to security issues).
Only company staff have company email address.
Outsource staff have personal email only.

If any machine is down or there's an issue, some outsourced staff cannot see the messages from Microsoft Teams.
Setting up a custom HTTP request in Power Automate to send messages through the WhatsApp Business API involves several steps. Here’s a detailed guide on how to achieve this
| Step | Description |
| ------ | ------------- |
| 1. Create a New Flow | Sign in to [Power Automate](https://flow.microsoft.com). Click on "Create" and select "Automated flow". |
| 2. Add a Trigger | Choose "When a new message is posted in a chat or channel" as the trigger. Select the Team and Channel from Microsoft Teams to monitor. |
| 3. Add an Action | Click on "New step" and select "HTTP" under the "Standard connectors". |
| 4. Configure the HTTP Request | Set the method to POST. Enter the URL for the WhatsApp Business API endpoint (`https://api.whatsapp.com/v1/messages`). |
| 5. Set Headers | Add headers:<br>- **Authorization**: Bearer {Your_Access_Token}<br>- **Content-Type**: application/json |
| 6. Set Request Body | Construct JSON payload:<br> |
```json
{
"to": "+1234567890",
"type": "text",
"text": {
"body": "@{triggerOutputs()?['body']?['content']}"
}
}
| 7. Save and Test Your Flow | Save your flow with a meaningful name. Test by posting a message in Microsoft Teams channel and verify message sending to WhatsApp. |
QUOTE
Explanation of Step 6 JSON Payload:
to: Replace +1234567890 with the recipient's WhatsApp number in international format.
type: Specifies the type of message, which can be text, image, audio, etc.
message.content.body:
Uses @{triggerBody()?['body']} to extract the message content from the Microsoft Teams trigger.
Adjust ['body'] based on the actual structure of your Teams message payload.
You can copy the markdown above and use it to guide you through setting up your flow in Power Automate.
Adjust the placeholders ({Your_Access_Token} and +1234567890) with your actual WhatsApp Business API access token and recipient's WhatsApp number respectively. This table provides a structured format to follow each step clearly.
to: Replace +1234567890 with the recipient's WhatsApp number in international format.
type: Specifies the type of message, which can be text, image, audio, etc.
message.content.body:
Uses @{triggerBody()?['body']} to extract the message content from the Microsoft Teams trigger.
Adjust ['body'] based on the actual structure of your Teams message payload.
You can copy the markdown above and use it to guide you through setting up your flow in Power Automate.
Adjust the placeholders ({Your_Access_Token} and +1234567890) with your actual WhatsApp Business API access token and recipient's WhatsApp number respectively. This table provides a structured format to follow each step clearly.
| Step | Description |
| ------ | ---------------------------------------------------------- |
| 1 | **Set Up Twilio for WhatsApp** |
| - Sign up for a Twilio account and verify your number. | |
| - Enable the WhatsApp Sandbox in Twilio to get a sandbox number for testing. | |
| - Note the Account SID and Auth Token from your Twilio Console. | |
| 2 | **Create a Power Automate Flow** |
| **Trigger**: Use the Microsoft Teams connector to trigger the flow when a new message is posted to a channel. | |
| 1. Go to [Power Automate](https://flow.microsoft.com). | |
| 2. Click on "Create" and choose "Automated flow". | |
| 3. Search for and select "Microsoft Teams" as the trigger. | |
| 4. Choose "When a new message is added to a channel" as the specific trigger. | |
| 5. Configure the Teams and channel details. | |
| **Action**: Use an HTTP request to send the message to the Twilio API. | |
| 1. Add a new step and search for "HTTP" action. | |
| 2. Configure the HTTP action as follows: | |
| - **Method**: POST | |
| - **URI**: `https://api.twilio.com/2010-04-01/Accounts/{AccountSID}/Messages.json` | |
| - **Headers**: | |
| - `Authorization`: Basic (Base64 encoded AccountSID:AuthToken) | |
| - `Content-Type`: application/x-www-form-urlencoded | |
| - **Body**: | |
| ```plaintext | |
| To=whatsapp:{Your_WhatsApp_Group_Number} | |
| From=whatsapp:{Your_Twilio_WhatsApp_Number} | |
| Body=@{triggerOutputs()?['body']['message']?['content']} | |
| ``` | |
| Replace `{AccountSID}`, `{Your_WhatsApp_Group_Number}`, and `{Your_Twilio_WhatsApp_Number}` with your actual Twilio Account SID, WhatsApp group number, and Twilio sandbox number respectively. | |
| 3 | **Test the Flow** |
| - Post a message in the Microsoft Teams channel to test the flow. | |
| - Verify that the message appears in your WhatsApp group. | |
| **Notes**: | |
| - For a production setup, you need to get your WhatsApp number approved by WhatsApp via Twilio. | |
| - Ensure your Power Automate and Twilio accounts are correctly configured and have the necessary permissions and credits. | |
| **Additional Considerations**: | |
| - You may want to add error handling steps in Power Automate to manage any issues with the HTTP requests. | |
| - Consider the security and privacy implications of forwarding messages from Teams to WhatsApp. |

This post has been edited by plouffle0789: Jun 27 2024, 07:24 AM
Apr 24 2024, 09:57 PM, updated 2y ago
Quote

0.0150sec
0.47
5 queries
GZIP Disabled