[Power Apps – PowerFx] Let’s try to deep link a Power apps to WhatsApp and Ms Teams using Named Formulas

You will see in this blog how we can initiate a Ms Teams call or a Whastapp chat from a Canvas app. Also, we will use the new concept “Named Formulas” to implement this scenario. Of course, we don’t have to use named formulas to implement this use case, this will give a first overview and the different possibilities and limitations regarding Named Formulas.

Scenario:

For the demonstration. I have a table that contains 3 rows. Each row is defined by the email and phone number columns. This table is displayed as a gallery, it contains two buttons. The first button will be used to initiate a MS Teams call using the email address, and the second button will be used to initiate a WhatsApp chat using the phone number.

When you click the Call in MS Team button, a call to the user will be initiated:

When you click the Call in “Start Chat in Whatsapp”, a chat will be initiated. The experience on the browser is described by the screenshot below. On Android or IOS, it is the WhatsApp app that will be directly opened.

How does it work ?

Both Teams and Whatsapp give us the ability to initiate conversations or calls via URLS. The trick is to build the right URL respecting the schema of each application. Then initiate a conversation or a call via the Launch() function.

For more details about the URL format, please refer to the following docs:

Personally, I have initiated the URL format using Named Formulas:

MsTeamsCallUrl = $"https://teams.microsoft.com/l/call/0/0?users={EmailForMsTeamCall}";
WhatsappChatUrl = $"https://wa.me/{PhoneNumberForWhatsappChat}";

EmailForMSTeamCall and WhasappChatUrl are declared as global variables. This will help to reuse the Formula as a Function in different parts of the App. Each time we use the two buttons, we just need to set the two global variables with the right values and call the Launch() Function.

The two Named Formulas will be updated each time the global variables are updated. This way we don’t have to recompute the URL with a concatenation.

Also, imagine if both Teams and Whatsapp applications change their URL format. We would need to change the Named Formula only. This will avoid changing the PowerFx formulas in different parts of our application. This example may not be very intuitive. But the introduction of the named Formula is a game changer and will save a lot of time in maintaining a Power Apps application.

Finally, Named Formulas are not functions ! Using a mix of global variables and named formulas allows us to implement something close to functions. According to the Power Apps team blog, in the future we will be able to implement functions without using components. For the moment, the Global Variable + Named functions approach allows implementing something similar to that.

Hope it helps …

One thought on “[Power Apps – PowerFx] Let’s try to deep link a Power apps to WhatsApp and Ms Teams using Named Formulas

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s