WhatsApp Business API | Integration with Microsoft Dynamics 365

Zapier logo

Hi there! 

Would you like to enhance your Microsoft Dynamics 365 communication capabilities with WhatsApp two-way communication?

In this tutorial, you will learn how to integrate Microsoft Dynamics with WhatsApp using the tyntec WhatsApp Business connector and Power Automate Flow. Using this integration, you can automatically start a Power Automate Flow on new incoming WhatsApp message and reply to it using free-form messages. 

You will need

  • Your tyntec API key from the Business Center
  • Your WhatsApp Business Account Number that has been assigned to you by tyntec
  • A testing Microsoft Dynamics account
  • A Microsoft Power Automate license in your Dynamics Environment
  • A testing phone with WhatsApp

Step One: Create your Flow

For a straightforward start with Power Automate and the tyntec WhatsApp Business connector, you will build a sample Flow. Let’s look at what it does.

The sample Flow works in your Microsoft Dynamics background and automatically listens to incoming WhatsApp messages. Once triggered, it checks if the current time matches your working hours and then Sends a WhatsApp Free-form Text message based on the time.

1. Open your Power Automate.

2. In the left dropdown menu, click the Create button.

3. From all possible Flow types, select Automated—from blank.

Automated flows run when an event triggers, Instant starts on a manual trigger, and Scheduled on a given time condition. 

4. In the design window pop-up, use the search function to find the event Incoming message from tyntec WhatsApp Business. Then click the Create button.

You are now in the UI Flow designer, in which you can add Actions to your Flow and chain them into algorithms. The designer automatically creates the Incoming message trigger step. When a new message is received, you have 24 hours to send any free-form message. After one day, you will be limited to template messages until a contact responds again.  

5. To create a new action, click the + New step. In the step selection, search for the Initialize variable action.

Search for initialize action

This action will hold the time entry. Set the name to Runtime, and type to Integer.

6. Click in the Value field and in the dropdown menu, select Expressions. Paste in the following code: int(replace(formatDateTime(utcNow(),'H:m'),':','')) and check if it looks like this screenshot. 

Be sure to have type = integer and the value = int(replace(formatDateTime(utcNow(),'H:m'),':',''))

Then press OK.

7. Click the  + New step. In the step selection, search for Condition, and select the Condition action. 

Search for Condition action

Set the Choose a value field to Runtime, the is equal to is less than or equal to, and the last field to your office start hour in the Hmm format. We used 800 for 8 AM.

use the Runtime defined earlier for the condition statement

Then, click on the + Add button to create a new condition. Select the Add row. 

Press Add, select add new row

Set the Choose a value field to Runtime, the is equal to is greater than or equal to, and the last field to your office end hour in the Hmm format. We used 1800 for 6 PM.

The first condition covers 00:00 until start of your work, second end of the work till 00:00

Lastly, click on And and set it to Or. The yes branch will run if a customer contacts you outside of your office hours. Otherwise, the if no branch runs.

Select Or

7. In the If yes branch, click the Add an action button. In the step selection, search for tyntec WhatsApp Business, and select the Send WhatsApp Free-form Text message action.

8. If this is your first time using the tyntec WhatsApp Business connector, Power Automate will automatically try to create a connection. Name your Connection and set your apikey to your tyntec API key. 

Create connection using custom name and your API key

Afterward, the Send WhatsApp Free-form Text message action updates itself to show you different fields:

9. Set the to field to from dynamic content, the from field to dynamic content.

10. Set the contentType to text and text to your automatic response.

11. In the if no branch, click the Add an action button. In the step selection, search for tyntec WhatsApp Business, and select the Send WhatsApp Free-form message action.

12. Set the to field to from dynamic content, the from field to dynamic content, the contentType to text, and text to your automatic response.

13. Click Save.

Your Flow will now automatically run when the Trigger detects a new incoming message.

 

Step Two: Test your Flow

Let's try triggering your Flow. 

1.Grab your phone and write a message to your WhatsApp business number. 

2. Within a few seconds, you will receive a reply determined by the current time. Voilà! To test a different response, you can change the numeric values in the Conditions action step.

two-way WhatsApp conversation

Congratulations on completing your Flow!

More?

The main power of the tyntec WhatsApp Business connector is that it is a quick, low-code, and hosted/deployed way to add functionalities to your internal tools. For example, if you have connected your Power Automate environment to Dataverse (Dynamics databases), you can use the Create a record to save incoming messages as any Dynamics table. 

That means by adding Create a record and contact look-up through phone number, you can save the incoming message as a note to the customer record in your Dynamics365. Moreover, you can look into our Microsoft Connector guide that uses a new record as its trigger. With modifications, it will allow your agents to send responses using contact Notes.