Send SMS Messages and Check for Replies Using Microsoft Power Automate Flows

Integrate the TNZ REST API with Microsoft Power Automate (Flows) to automate sending SMS messages from Dynamics 365, Forms, or other apps and check for replies.

What is Microsoft Power Automate (Flows)?

Microsoft Power Automate (formerly known as Microsoft Flow) is a powerful cloud service that helps you create automated workflows (called Flows) between your favourite apps and services to synchronise files, get notifications, collect data, and more.

Power Automate lets you bridge the gap between different software, triggering an action in one app based on an event in another.

 

Why Use Power Automate for SMS?

Integrating Power Automate with the TNZ REST API allows you to automate SMS communication based on events happening in your Microsoft ecosystem and beyond.

This is highly beneficial for:

  • Notifications: Send an immediate SMS to a customer when a form is submitted, an invoice is paid in Dynamics 365, or a task is assigned.

  • Workflows: Automate sending an SMS confirmation after a new entry is created in a SharePoint list.

  • Communication: Use SMS in your communications strategy without writing custom code for every application.

 

Integration Possibilities with Power Automate

Power Automate is designed to work with a vast array of services and applications, allowing you to use almost any event as a trigger to send a TNZ SMS. Some of the most common applications include:

  • Microsoft Dynamics 365: Trigger an SMS notification when a Lead is qualified, a Case is updated, or a Sales Order is created.

  • Microsoft Forms: Send an automated SMS to the submitter (if they provide their number) or an internal team when a new survey or support request is submitted.

  • SharePoint: Send an alert when a new item is added to a List or a document is approved in a Library.

  • Outlook: Send an SMS alert for an urgent email from a specific sender.

  • Other Services: Connect to hundreds of services like Twitter, Salesforce, Dropbox, and more.

 

Setting Up a Flow to Trigger a TNZ SMS

To send an SMS, you'll use the HTTP action within Power Automate to make a POST request to the TNZ SMS API endpoint.

Note: The HTTP actions are typically a premium feature and requires a Power Automate license.

1. Access Power Automate

Go to the Power Automate portal and sign in with your Microsoft account.

2. Create a New Flow

  • Select + Create from the left navigation pane.

  • Choose Instant cloud flow (you can later change this to an automated flow based on your desired trigger).

Microsoft Power Automate - Instant Cloud Flow

  • Enter a Flow name (e.g., "SMS Sender").

  • Choose your desired trigger. For testing, select Manually trigger a flow and click Create.

Microsoft Power Automate - New Flow - Send SMS

3. Add the HTTP Action

  • Click + New step.

  • Search for HTTP and select the standard HTTP action (ensure you are using the core HTTP action, not a specific one like 'Office 365 Outlook | Send an HTTP Request').

  • Click on the HTTP action to expand it.

Microsoft Power Automate - Add HTTP Action

 

4. Configure the HTTP Action (Code View)

To ensure the structure is correct, it's best to start in Code view.

  • Click the Code view tab at the top right of the HTTP action box.

  • Paste the following JSON data into the editor. This provides a template for sending an SMS via the TNZ API.

{
  "type": "Http",
  "inputs": {
    "uri": "https://api.tnz.co.nz/api/v3.00/sms",
    "method": "POST",
    "headers": {
      "Content-Type": "application/json; encoding='utf-8'",
      "Accept": "application/json; encoding='utf-8'"
    },
    "body": {
      "Message": "Hello @{triggerOutputs()?['headers']?['x-ms-user-name']}, this is a test from Power Automate.",
      "Destination": "+6421000001"
    },
    "authentication": {
      "type": "Raw",
      "value": "Basic 12341234"
    }
  },
  "runAfter": {}
}

 

5. Finalize Configuration (Parameters Tab)

  • Switch back to the Parameters tab and validate the values.

    • Method: POST.

    • URI: https://api.tnz.co.nz/api/v3.00/sms

    • Headers: Should include Content-Type and Accept headers.

    • Body: The body contains the message payload. You can insert Dynamic Content (like a phone number from a Form submission or a user name from the flow trigger) by placing your cursor in the field and pressing the / key or clicking the Dynamic content option.

    • Authentication: Change Basic 12341234 to your actual TNZ Auth Token. This token authenticates your request. To find your Auth Token, see: Managing API Users

6. Save and Test the Flow

  • Click Save.

  • Click Test in the top-right corner.

  • Choose Manually and click Test again. Follow the prompts to run the flow and check your phone for the SMS.

 

Setting Up a Flow to Check for Received SMS Messages

TNZ can fire a webhook when a message is received. Use the Power Automate HTTP Request function to catch and report on these webhooks.

Note: The HTTP actions are typically a premium feature and requires a Power Automate license.

1. Access Power Automate

Go to the Power Automate portal and sign in with your Microsoft account.

2. Create a New Flow

  • Select + Create from the left navigation pane.

  • Choose Instant cloud flow (you can later change this to an automated flow based on your desired trigger).

  • Enter a Flow name (e.g., "SMS Receiver").

  • Select When an HTTP request is received and click Create.

Microsoft Power Automate - New Flow - Receive SMS

3. Add the HTTP Action

  • Click on the HTTP step ("manual")

  • Rename the step (e.g. "Receive SMS Webhook from TNZ")
    Microsoft Power Automate - New Flow - Receive SMS Rename
  • Set Who can trigger the flow to Anyone
  • Select the Code view tab and paste the following JSON data:
    {
    "type": "Request",
    "kind": "Http",
    "inputs": {
    "triggerAuthenticationType": "All",
    "schema": {
    "type": "object",
    "properties": {
    "Version": {
    "type": "string"
    },
    "Sender": {
    "type": "string"
    },
    "APIKey": {
    "type": "string"
    },
    "Type": {
    "type": "string"
    },
    "Destination": {
    "type": "string"
    },
    "ContactID": {
    "type": "string"
    },
    "ReceivedID": {
    "type": "string"
    },
    "MessageID": {
    "type": "string"
    },
    "SubAccount": {
    "type": "string"
    },
    "Department": {
    "type": "string"
    },
    "JobNumber": {
    "type": "string"
    },
    "SentTimeLocal": {
    "type": "string"
    },
    "SentTimeUTC-ISO8601": {
    "type": "string"
    },
    "SentTimeUTC-RFC3339": {
    "type": "string"
    },
    "Status": {
    "type": "string"
    },
    "Result": {
    "type": "string"
    },
    "Message": {
    "type": "string"
    },
    "Price": {
    "type": "string"
    },
    "Detail": {
    "type": "string"
    },
    "URL": {
    "type": "string"
    }
    }
    },
    "method": "POST"
    } }

     

  • Set up an appropriate Action, such as Adding a row into a spreadsheet table.
    Microsoft Power Automate - New Flow - Receive SMS - Add Spreadsheet Row

  • Save the Flow.

  • Open the Receive SMS Webhook from TNZ step and copy the HTTP URL.

4. Use the new Webhook URL

Finally, you'll need to tell TNZ about your new Webhook URL.

Setting a Webhook as your Default Reporting Method

You can set up your API user to specify the Webhook by default.

Follow this guide: Configuring API Webhooks

Setting a Webhook when Submitting a Message

You can specify the Webhook URL when submitting a message. 

For example, modify your Send SMS flow and add these fields to the Body:

    "body": {
      "NotificationType": "Webhook",
"WebhookCallbackURL": "[[Your Webhook URL]]", "WebhookCallbackFormat": "JSON" },

 


Topics:   Installation SMS

Start your free trial today!

Ready to revolutionise your messaging?
Connect with people anywhere - boost engagement, responses and conversations.

20 credits over 14-days. No obligation. No credit card required.