Alert to MS Teams

Hi Guys,

I checked the previous posts but I couldnt see any solution.

I have setup an ms teams alert transport, I click on the test button and it shows “transport to ms teams ok” but Im not getting any message on the channel. I see the below error on teams logs :

ExpressionEvaluationFailed. The execution of template action ‘Send_each_adaptive_card’ failed: the result of the evaluation of ‘foreach’ expression ‘@triggerOutputs()?[‘body’]?[‘attachments’]’ is of type ‘Null’. The result must be a valid array.

I tested directly a payload on the cli with the below command and i can see the message on teams
curl -H “Content-Type: application/json” -d “@/root/payload.json” “https://mywebhooklink

any help with this one plz ?

Can you post your alerts template?

I’m using now emails alerts because I unfortunately gave up on trying to make it work with teams webhooks unless you have a better idea ?

my email template looks like below but thats irrelevant to my issue :slight_smile:

Severity State Timestamp Device Issue
{{ $alert->severity }} {{ $alert->state }} {{ $alert->timestamp }} {{ $alert->hostname }} {{ $alert->name }}

It took me a bit to get my webhooks working. My webhook tested good however my alerts template wasn’t being received via teams. I re-wrote my alerts template and now all my alerts are sent to different channels on teams with different alert templates.

can you please post your template, I will test it and check if it works for me, many thanks in advance

Here is my default one. I typically modify for each alert to ensure I’m getting the data I want in the alert based on what the issue is.

{{ $alert->title }}
Severity: {{ $alert->severity }}
@if ($alert->state == 0) Time elapsed: {{ $alert->elapsed }} @endif
Timestamp: {{ $alert->timestamp }}
Unique-ID: {{ $alert->uid }}
Rule: @if ($alert->name) {{ $alert->name }} @else {{ $alert->rule }} @endif
@if ($alert->faults) Faults:
@foreach ($alert->faults as $key => $value)
#{{ $key }}: {{ $value[‘string’] }}
@endforeach
Alert sent to:
@foreach ($alert->contacts as $key => $value)
{{ $value }} <{{ $key }}>
@endforeach
@extends(‘alerts.templates.default’)
Alert sent to:
@section(‘content’)
{{ $alert->title }}
Severity: {{ $alert->severity }}

@endsection
@endif

I try to use this one and when I click on update, the error message show up : undefined constant alert

how did you define this constant ?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.