Send alerts to Microsoft Teams and email alerts about unsent and failed emails
Effective communication is crucial for maintaining strong relationships with customers and ensuring seamless business operations. In scenarios in which message delivery issues occur, such as unsent and failed messages, these disruptions can impact customer satisfaction and operational efficiency.
This use case focuses on implementing a comprehensive monitoring and alert system for unsent and failed messages.
By using Synerise’s the Automation module, businesses can distribute detailed daily reports and set up real-time alerts to notify channel members in Microsoft Teams and send email alerts when message delivery issues occur.
This proactive approach helps maintain communication reliability and enhances customer satisfaction. In our case we will start this automation daily to check the number of message.notSent
events and the list of possible errors. The message alert will be sent only if the number of unsent messages will be higher or equal to 1
.
message.notSent
event, which is generated when the process of sending an email fails.
However, it can be easily adapted by incorporating additional events that are generated when delivery issues occur in different communication channels. For instance, events like push.notSent
or webpush.notSent
can be included to ensure a broader scope of monitoring.Prerequisites
Create a workflow from a channel in Teams by following steps below:
- Go to Power Automate to create a workflow from a channel in Teams. Save workflow to generate incoming webhook URL.
- Edit the created workflow by filling out the TeamId and ChannelId fields. These values will be suggested. If not:
- To get the value of TeamId, go to the MS Teams application and retrieve a link to the team. TeamId is the part of generated URL groupId=XXXX.
- To get the value of ChannelId, go to the MS Teams application and retrieve a link to the channel. ChannelId is a part of generated URL channel/XXXXXXXX.
- Save the changes in the workflow.
- If you want to send an interactive message (such message can contain links, simple surveys, sections), prepare it in AdaptiveCard.
Process
In this use case, you will go through the following steps:
- Create a metric which counts the occurrences of
message.notSent
events. - Create a report.
- Create an email template that contains description of error parameters.
- Create a workflow which sends an email alert.
- Create a workflow which sends the message to the Microsoft Teams channel.
Create a metric
In this part of the process, we will create a metric whose result will be later sent in the Microsoft Teams message. This specific metric will count the number of unsent email messages.
- In Synerise, go to
Analytics > Metrics > New metric.
- Enter the name of the metric.
- As the metric type, choose Simple metric.
- From the Type dropdown, choose Event.
- As an aggregator, choose Count.
- From the Choose event dropdown list, select
message.notSent
. - Set the time range to Yesterday.

Create a report
In this part of the process, we will create a report whose results will be later sent in the Microsoft Teams message.
-
Go to
Analytics > Reports > New report.
-
Enter a meaningful name of the report.
-
From the Choose metric dropdown list, select a metric created in “Create a metric” part of the process.
-
From the Range dropdown list, select the number. This number should be linked to the average number of campaigns sent daily and may therefore be smaller or larger depending on the business. In this case it will be TOP 20.
-
In the Dimension section, from the dropdown list, select Event > Parameters. From the list, select the following parameters:
- campaignName
- info
- extra
- exception
- id
- diagramId
Note:- You can find descriptions of these parameters in the documentation for the
message.notSent
event. - If needed, you can add more parameters, reduce its number, or modify them to suit your specific business requirements.
-
Choose Show null values.
-
Using the date picker in the lower-right corner, set the time range to Yesterday.
-
Save the report.

Create an email template
You can use a ready-made template (available on the Synerise Demo workspace) that inserts the data you want to send in a table format.
-
On the right panel, click the Config tab.
-
Fill out Title and Subtitle to personalize the header and subtitle in the template.
-
Define Maximum report table rows number.
-
In Report id, enter the ID of the report you created within “Create a report”.
You can retrieve the report ID by going to Analytics > Reports. On the list of reports, find the report you created in the previous part of the process. To the right side of the report author, expand the context menu and at the bottom of the list, copy the ID. -
In the General Settings section:
- From the Synerise environment dropdown, select the cloud where your workspace is hosted.
- From the Campaign type dropdown, select email.
-
Click Save as.
-
On the pop-up, you can change the name and select the folder where the template will be saved.
The configuration of the email template
Create a workflow
In this part of the process, you will create a workflow that sends a message with the report results through email once a day. The message alert will be sent only if the number of unsent messages will be higher than 1
.
- In Synerise, go to Automation > Workflows > New workflow.
- Enter the name of the workflow.
Define the Scheduled Run trigger node
At this stage, configure the conditions that trigger the workflow.
- As the trigger node, select Scheduled Run.
- In the configuration of the node:
- Change the Run trigger option to all time.
- Choose the Everyday option.
- Choose the timezone and hour (in our case, it’s 6.00 A.M.)
- Confirm by clicking Apply.

Choose Get Analytics Report Node
- Choose Get Analytics Report.
- From the dropdown list, select the report created in “Create a report” part of the process.
- Set report records limit.
- Click Apply.

Define the Metric Filter node
In the Metric Filter node, you will select the metric prepared in “Create a metric” part of the process. The continuation of the workflow will depend on the result of the metric. If the metric result is equal to or more than 1, an alert will be sent.
- Add Metric Filter.
- In Define condition, choose the metric created in the previous step.
- As the condition, by using the mathematical operators, set the metric result as equal or more than
1
. - Click Apply.

Define the Email Alert Node
- Add the Email Alert node to the matched path. In the configuration of the node:
- In the Content section, select the email template created in the previous step and in the Subject field, enter your message subject.
- In the Recipient section, use the text field to add at least one email address of a workspace user to whom the message will be sent.
- Confirm the selection by clicking Add.
- Confirm by clicking Apply.
Add the finishing node
- Add the End node:
- To the Not matched path,
- After the Email Alert node.
- In the upper right corner, click Save & Run.

Create a workflow sending Teams alert
In this part of the process, you will create a workflow that sends a message to the Microsoft Teams channel once a day. The workflow will look similar to one created previously but instead of the Email Alert node, we use the Send Channel Message node. Its settings are described below.
Send channel message
In this step, you will configure the settings of the outgoing integration that sends the alert message to Microsoft Teams channel.
- Add the Send Channel message node.
- In the configuration of the node:
- If you already created a connection, select the connection from the list.
- If you haven’t created any connection yet:
- At the bottom of the dropdown list, click Add connection.
- In the Incoming Webhook URL field, enter the incoming webhook URL you created as a part of prerequisites.
- Click Next.
- In the Connection name field, enter the name for the connection you created.
- Click Apply.
Result: A connection is created and selected.
- In the Type of message field, choose Interactive message (JSON).
- Below, in JSON body, add the content of the message which will be sent to the Microsoft Teams channel.
In the code below, remember to replace a few things:
set mentions
: Replace email addresses with emails of workspace users who are supposed to be mentioned on the Teams channel when a new report is available.set reportId
: Set this to the ID of the report created in “Create a report”.set env
: Replace this with the environment your workspace is hosted.set campaignType
: Replace this with the type of campaign, in our case: email.
{#CONFIG#}
{% set mentions = ['abc@synerise.com','xyz@synerise.com']%} {# you can leave array empty []#}
{% set title = "Message.notSent alert" %}
{% set reportId = 'f3370785-f309-4b6f-b47f-bb10de377708' %}
{% set env = 'microsoft' %} {# microsoft, google #}
{% set campaignType = 'email' %} {# email, sms, mobile-push, webpush #}
{#ENDCONFIG#}
{% set baseUrl = 'https://app.geb.synerise.com' if env == 'google' else 'https://app.synerise.com' %}
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.4",
"body": [
{
"type": "TextBlock",
"text": "{% for mention in mentions %}<at>{{mention}}</at>{% if not loop.last %}, {% endif %}{% endfor %}",
"size": "small"
},
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "{{title}}"
},
{
"type": "Table",
"columns": [
{
"width": 1
},
{
"width": 1
},
{
"width": 1
},
{
"width": 1
},
{
"width": 1
}
],
"rows":
{% set dataRow=[] %}
{% set titles=['campaignName', 'info', 'extra', 'value', 'campaignId'] %}
{% set cells = [] %}
{% for t in titles %}
{% do cells.append(
{
"type": "TableCell",
"items":
[
{
"type": "TextBlock",
"text": t,
"wrap": true
}
]
}
) %}
{% endfor %}
{% do dataRow.append({"type": "TableRow","cells":cells}) %}
{% datareference node='Get report' maxRows=12 %}
{% set cells=[] %}
{% for r in datareference_result %}
{% set cells=[
{
"type": "TableCell",
"items":
[
{
"type": "TextBlock",
"text": r.campaignName +' [[link]]('+baseUrl+'/campaigns/'+campaignType+'/preview/'+r.id+')',
"wrap": true
}
,
{
"type": "TextBlock",
"text": 'Automation [[link]]('+baseUrl+'/automations/workflows/automation-diagram/'+r.diagramId+')' if r.diagramId is not string_containing 'null' else '',
"wrap": true
}
]
},
{
"type": "TableCell",
"items":
[
{
"type": "TextBlock",
"text": r.info,
"wrap": true
}
]
},
{
"type": "TableCell",
"items":
[
{
"type": "TextBlock",
"text": r.extra,
"wrap": true
}
]
},
{
"type": "TableCell",
"items":
[
{
"type": "TextBlock",
"text": r.Value|int,
"wrap": true
}
]
},
{
"type": "TableCell",
"items":
[
{
"type": "TextBlock",
"text": r.id,
"wrap": true
}
]
}
]%}
{% do dataRow.append({"type": "TableRow","cells":cells}) %}
{% endfor %}
{% enddatareference %}
{{dataRow|tojson}}
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "Raport",
"url": "{{baseUrl}}/analytics/reports/{{reportId}}"
}
],
"bleed": true,
"msteams": {
"width": "Full",
"entities": [
{% for mention in mentions %}
{
"type": "mention",
"text": "<at>{{mention}}</at>",
"mentioned": {
"name": "{{mention}}",
"id": "{{mention}}"
}
}
{% if not loop.last %}
,
{% endif %}
{% endfor %}
]
}
}
- Confirm by clicking Apply.

Add the finishing node
- Add the End node after Send channel message and to the not matched path.
- In the upper right corner, click Save & Run.

Check the use case set up on the Synerise Demo workspace
Directly in our Synerise Demo workspace, you can check the configuration of:
If you don’t have access to the Synerise Demo workspace, please leave your contact details in this form, and our representative will contact you shortly.