Email Template Adaptive Card Activity

The BotEmailTemplateAdaptiveCardActivity enables developers to send Adaptive Card messages to any active bot conversation using the Email Template. EmpowerID already supports the use of formatted email templates while sending emails from the system; the purpose of building the Email Template Adaptive Card Activity is to reuse the same email templates to send an adaptive card output to the channels.

Developers can also design and bind the adaptive Card inside WFS; more instructions can be found here.

You can find the BotEmailTemplateAdaptiveCardActivity in the Activities toolbox in Workflow Studio. Drag and drop the activity into your workflow to use the activity in a workflow.

 

Properties

The BotEmailTemplateAdaptiveCardActivity provides the following properties for you to develop an Adaptive Card.

Important Concept: Person.BotConversationReferenceID

A conversation reference ID is required to initiate a conversation with a user proactively. A reference ID implies that the user or Person has an active conversation. A conversation expires if the user closes the communication channel or logs out of the channel (i.e., Teams, Web Chat, etc.). An expired conversation will not have a valid Reference ID, and such a conversation cannot receive messages. Whenever you write any logic for proactive messaging, you should retrieve and check the conversation reference ID from the Person.BotConversationReferenceID

Property

Type

Description

Property

Type

Description

BotTenantId

string

BotTenantId Specifies the Tenant ID. The administrator can retrieve the Bot Tenant ID of your organization from the Azure portal.

BotConversationReferenceId

GUID

BotConversationReferenceId Specifies the Conversation Reference ID of the user to whom you are sending the message(i.e., Person.BotConversationReferenceID)

MessageType

TheDotNetFactory.Framework.BotWF.Common.ProactiveMessageType

MessageType Specifies how the proactive message should be delivered to the user. The ProactiveMessageType is an enum with the following values:

  • ShowToUserImmediately – The user will receive and see the complete message immediately. You can use this type to send urgent messages.

  • NotificationReminder – The Message is delivered to the user's notification list, and a Message Reminder is shown to remind the user to check the notification list.

  • NotificationOnly – The Message is delivered to the user's notification list. There will be no additional action or reminders.

MessageReminder

string

MessageReminder is the Text to show as a reminder to the user indicating that the user has received a message in the notification list.

CustomProactiveMessage

TheDotNetFactory.Framework.BotWF.Common.BotCapability

You may use this property to support the advanced handling of proactive messaging.

EmailMessageID

int

The Email Message Template ID to send as an Adaptive Card.

EmailSubjectFormatter

Dictionary<string, object>

The EmailSubjectFormatter is a dictionary with placeholders and values to format the Email Subject.

EmailBodyFormatter

Dictionary<string, object>

The EmailBodyFormatter is a dictionary with placeholders and values to format the Email Body.

UseExistingTemplate

Boolean

The UseExistingTemplate property determines whether to use the existing bot template or create a new adaptive card template from the inputs provided. E.g., If true, input will be sent to an existing email template. If false, a new card will be created and saved in the database based on the data.

HasDatatable

Boolean

The HasDatatable property specifies if the email template is a datatable. If set true a datatable or the next property described here, EmailTemplateTableFormat has to be passed.

EmailTemplateTableFormat

DataTable

EmailTemplateTableFormat is the datatable input if the email template contains a table.

 

Adaptive Card Using a Basic Email Template

Please find the instruction below to create an adaptive card with an email template without HTML formatting.

  1. Add a BotEmailTemplateAdaptiveCardActivity to your workflow.

  2. In the BeforeExecute event of the activity, add the code below.


    Dictionary<string, object> subjectProperties = new Dictionary<string, object>(); subjectProperties["CurrentOperationName"] = "Dev Machine"; Dictionary<string, object> bodyProperties = new Dictionary<string, object>(); bodyProperties["CurrentOperationName"] = "Dev Machine"; this.CurrentWorkflow.SendNotificationFromEmail.EmailMessageID = 4; this.CurrentWorkflow.SendNotificationFromEmail.UseExistingTemplate = true; this.CurrentWorkflow.SendNotificationFromEmail.EmailSubjectFormatter = subjectProperties; this.CurrentWorkflow.SendNotificationFromEmail.EmailBodyFormatter = bodyProperties; this.CurrentWorkflow.SendNotificationFromEmail.BotTenantId = ""; var person = Person.GetByPersonGUID(new Guid("")); this.CurrentWorkflow.SendNotificationFromEmail.BotConversationReferenceId = (Guid)person.BotConversationReferenceID; this.CurrentWorkflow.SendNotificationFromEmail.MessageType = BotWF.Common.ProactiveMessageType.ShowToUserImmediately;



You should be able to see an adaptive card in your MS-Teams window.

 

Adaptive Card using HTML Formatted Email Template

Please find the instruction below to create an adaptive card and perform the HTML formatting in the Email Body. This example shows how you can use an already existing Email Template.

  1. Add a BotEmailTemplateAdaptiveCardActivity to your workflow.

  2. In the BeforeExecute event of the activity, add the code below.

Dictionary<string, object> subjectProperties = new Dictionary<string, object>(); subjectProperties["BusinessProcessID"] = "Test"; subjectProperties["CurrentOperationName"] = "Dev Machine"; Dictionary<string, object> bodyProperties = new Dictionary<string, object>(); bodyProperties["OperationsPendingApproval"] = "Yes, pending approval."; bodyProperties["Initiator.FriendlyName"] = "Koq"; bodyProperties["Initiator.Email"] = "ja@js.com"; bodyProperties["Initiator.Telephone"] = "+912584789632"; bodyProperties["AttributesModificationSummary"] = "Dev Machine"; this.CurrentWorkflow.SendNotificationFromEmail.EmailMessageID = 1; this.CurrentWorkflow.SendNotificationFromEmail.UseExistingTemplate = true; this.CurrentWorkflow.SendNotificationFromEmail.EmailSubjectFormatter = subjectProperties; this.CurrentWorkflow.SendNotificationFromEmail.EmailBodyFormatter = bodyProperties; this.CurrentWorkflow.SendNotificationFromEmail.BotTenantId = "55E8A89F-782B-41EF-B004-43102014B84E"; var person = Person.GetByPersonGUID(new Guid("599A413F-30D0-4094-9139-B61EC217F38F")); this.CurrentWorkflow.SendNotificationFromEmail.BotConversationReferenceId = (Guid)person.BotConversationReferenceID; this.CurrentWorkflow.SendNotificationFromEmail.MessageType = BotWF.Common.ProactiveMessageType.ShowToUserImmediately;

You should be able to see an adaptive card with the formatted body in your team's window.

Adaptive Card using HTML Formatted New Email Template

Suppose there is no email template already in the database, and it needs to be created for an adaptive card. Please follow the same steps described above for Adaptive Card using HTML Formatted Email Template but make sure you set the UseExistingTemplate property to false.

this.CurrentWorkflow.SendNotificationFromEmail.UseExistingTemplate = false;

Adaptive Card using Data Table and New Email Template

Developers would use a Data Table when they have to show the data in tabular format.

Please find the instruction below to create a New adaptive card using the Data Table. A New adaptive card means we will save a new email template while we build an adaptive card.

  1. Add a BotEmailTemplateAdaptiveCardActivity to your workflow.

  2. In the BeforeExecute event of the activity, add the code below.

     

You should be able to see an adaptive card with a formatted body with a tabular output in your team's window.

 

 

 

Proactive Bot Message

EmpowerID Chatbot

Publish BotFlow from EID Chatbot

 

 

 

 

Â