Skip to content

Consistent email signatures with Power Platform

An organization typically has a template for signing emails.

Equally typical is that no one knows where to find that template. In practice, the signature is copied from an email from a colleague. The one whose signature looks the most stylish.

As a result, there are many variations on the look of email signatures.

I have been asked if this problem could be solved in any way with Power Platform tools.

The answer is yes.

So, let’s make a Power App to maintain the organization’s official signature templates. With the same application, users can download the signature (filled with their own information).

In addition, let’s provide the users a Power Virtual Agent from whom they can request the latest signature template, which is again filled with their own information.

Dataverse for Teams is a nice platform for this. Let’s get started!

Data storage

Let’s create a table, where the signature templates are stored (EmailSignatureTemplate). The table has three columns

  • The template name (Name)
  • Is the template currently in use (Is in use)
  • The actual template in html format (SignatureTemplate)

Maintaining signature templates (Power Apps)

Next, let’s create a new Power App for Teams (Power Apps -> Create an app).

The same team we just created the EmailSignatureTemplate table in is selected.

Power Apps creates a single screen template app for us. Let’s switch the data source of the from to the correct one (EmailSignatureTemplate) by clicking Connect to Data.

Like this.

After this, the gallery on the left is edited to point to the same data source.

Now we have a screen ready to maintain different signature templates!

Let’s customize the screen to serve our use case a little better.

The signature templates are saved in html format. User-specific information (name, phone number, email, title etc.) is enclosed in the templates inside parentheses (e.g. {displayname}, {email}, etc.).

Downloading your own signature (Power Apps)

Let’s add a new blank screen and the following controls to the application

  • Screen title
  • Drop-down menu (combo box), for selecting the signature model
  • Text fields for the user’s title and phone number

The values in the drop-down menu are all of the available templates.

Items: Filter(EmailSignatureTemplates, 'Is in use' = 'Is in use (EmailSignatureTemplates)'.Yes) 

The user’s title is retrieved from their profile.

Text: Office365Users.MyProfileV2().jobTitle 

The phone number can be retrieved in a similar way.

Next, let’s add a vertical container (1) to the screen and place it in an appropriate location. A title (2) and an html text field (3) are then placed inside the container.

The height of the html field is set to be flexible (Flexible height = On).

The content of the html field is the selected template (cmbSignatureTemplate.Selected.SignatureTemplate) filled with user’s data.

Like this.

Substitute(
  Substitute(
    Substitute(
      Substitute(
        cmbSignatureTemplate.Selected.SignatureTemplate,
        "{Mail}",
        Office365Users.MyProfileV2().mail
      ),
      "{DisplayName}",
      Office365Users.MyProfileV2().displayName
    ),
    "{JobTitle}",
    inpJobTitle.Value
  ),
  "{Phone}",
  inpPhone.Value
 )
)

Sending the signature template

How do we deliver the filled template to the user? They need a file that can be copied to the correct folder on their workstation.

The easiest way to do this is with the flow, which is launched from Power Apps with a button. The flow gets the name and contents of the file to be created as a parameter.

The flow consists of the following parts

  • Retrieve the profile of the user who started the flow (we need the username)
  • Create a file (on the user’s own OneDrive)
  • Send the file to the user as an email attachment
  • Delete the created file from OneDrive

After pressing the button, the user receives an e-mail with a completed signature file attached.

Limiting administration to team owners

The application has two screens.

  1. Generate the signature from a selected template
  2. Maintenance of signature templates

Only team owners have access to the admin screen. The owners are the administrators of the Dataverse for Teams environment that corresponds to the team.

Let’s determine whether the app user has a System Administrator security role in this environment when the Power Apps starts (App OnStart).

If yes, this information is set in the variable varUserIsAdmin.

ClearCollect(colSysAdmis, LookUp('Security Roles', Name ="System Administrator").Users.'Primary Email');
Set(varUserIsAdmin,!IsBlank(LookUp(colSysAdmis, ThisRecord.'Primary Email' = User().Email)))

This allows us to add an icon to the home screen, that the users can press to navigate to the admin screen. The icon is only visible to team owners.

Requesting your own signature (Power Virtual Agents)

Dataverse for Teams provides us with a convenient Power Virtual Agent. Let’s give the users the opportunity to request their own signature file directly from a chatbot.

Let’s go to Power Apps inside Teams and create a new bot (New -> Chatbot).

Give a name and choose the language for the bot.

Add a topic that corresponds to the subject (delivering the signature).

As well as a few example phrases, which direct the bot to this topic.

And finally, we get to define the functionality of the bot (Go to authoring Canvas).

The bot uses flow to generate the signature file. Create a new flow (plus symbol -> call an action -> Create a flow).

From the options, select a flow that starts from the Power Virtual Agent and returns a value to it.

The userid is set as the input parameter.

Then we get the user profile, as well as the official signature template.

A signature file is then created to a SharePoint document library, complete with the user’s information. The data is added with the replace function.

replace(outputs('Get_a_row_by_ID')?['body/crb24_signaturetemplate'],'{DisplayName}',outputs('Get_user_profile_(V2)')?['body/displayName'])

We have to make several of these nested, just like in the Power Apps example we just did.

Finally, a link to the generated file is returned to the Power Virtual Agent.

We don’t want to leave old signature files in the document library, so a parallel branch is added to the end of the flow, where the generated file is deleted after an hour.

Go back to our chatbot, and add the flow we just made as an action (Call an action).

Define the id of the user using the bot (bot.UserId) as the value for the flow parameter. After running the flow, the user will be provided with the link to the generated signature file and instructions for setting it up.

The bot needs to be published (Publish) so others can use it too.

The finished bot looks like this.

Summary

The solution we just built is quite neat. But it is not yet completely ready. Special characters will cause problems, and they need to be replaced (ä -> & auml etc.) for the signature to work.

The app could also be tuned to support dark mode in Teams, but let’s leave it as is.

ChatbotDataverse for TeamsEmail signatureFlowOffice 365OutlookPower AppsPower Virtual Agent

Leave a Reply

Your email address will not be published. Required fields are marked *