How to send a message to a teams channel via Power Automate
Asked by Martin Hirsch:

We are using connectors to send messages about new tickets to a teams channel. MS will not longer support this, so we have to use power automate. No i want to use webhooks, but in my workflow the followin error occurs:

Setting in Jira Automation:

**![image.png](/t5/image/serverpage/image-id/335611i6DB17D027132E6CE/image-size/large?v=v2&px=999 "image.png")**

**ExpressionEvaluationFailed** . The execution of template action 'Send_each_adaptive_card' failed: the result of the evaluation of 'foreach' expression 'Test@{triggerBody()}' is of type 'String'. The result must be a valid array.

Any idea to this?


Answers:
author: Vikrant Yadav
body: Hi [@Martin Hirsch](/t5/user/viewprofilepage/user-id/4829498) You have to use Workflow in MS Team , create flow similar to below screenshot :

![Screenshot 2024-07-15 at 5.37.42?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/335645i9C188E2D33F592B7/image-size/large?v=v2&px=999 "Screenshot 2024-07-15 at 5.37.42?PM.png")

![Screenshot 2024-07-15 at 5.39.06?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/335646i4145A1931798ED46/image-size/large?v=v2&px=999 "Screenshot 2024-07-15 at 5.39.06?PM.png")

<br />

<br />

comments: author: Martin Hirsch
body: Thanks for help. Now i'm getting this error:

**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.


author: Hugo Fernandes
body: Is there an update about this issue?


author: Vikrant Yadav
body: [@Martin Hirsch](/t5/user/viewprofilepage/user-id/4829498) [@Hugo Fernandes](/t5/user/viewprofilepage/user-id/5569864) Try to add compose action before send each adaptive card and put dynamic content body only. It seems that body.attachment is not a correct dynamic content.


author: Andras M
body: [@Vikrant Yadav](/t5/user/viewprofilepage/user-id/1801711) when selecting Body (with capital B?) for Compose as dynamic content (and also for Send each adaptive card)  

![compose-input.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/343453i1633710298DA987D/image-size/large?v=v2&px=999 "compose-input.jpg")

still I got an error message

```
ExpressionEvaluationFailed. The execution of template action 'Send_each_adaptive_card' failed: the result of the evaluation of 'foreach' expression '@triggerBody()' is of type 'Object'. The result must be a valid array.
```

![failed.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/343455iDFDBEA87B5F0FFC6/image-size/large?v=v2&px=999 "failed.jpg")

Also, when selecting Compose Output for the Send each adaptive cart, got error

<br />

![output.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/343461iDE069475A969A494/image-size/large?v=v2&px=999 "output.jpg")  

```
ExpressionEvaluationFailed. The execution of template action 'Send_each_adaptive_card' failed: the result of the evaluation of 'foreach' expression '@outputs('Compose')' is of type 'Object'. The result must be a valid array.
```


author: Vikrant Yadav
body: Hi [@Andras M](/t5/user/viewprofilepage/user-id/4888833)

In Jira, Use Send Web Request action and in body select "Custom Data" . In Custom Data, capture only those fields in which you want to post on MS Teams Channel.   

In MS Team \>\>   

1. When a Teams Webhook request is recevied

2. Initialie variable \>\> Give name , type should be Object \>\> in value select Body dynamic content.

3. Compose item : write expression \>\> variables('JiraData')?\['Summary'\]

4. Post a message in a chat. In message i have selected Compose output.

![Screenshot 2024-08-24 at 10.24.21?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/343644iBDBE965D0CBECD35/image-size/large?v=v2&px=999 "Screenshot 2024-08-24 at 10.24.21?PM.png")![Screenshot 2024-08-24 at 10.25.33?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/343642iEB31F1A1C2E1F85B/image-size/large?v=v2&px=999 "Screenshot 2024-08-24 at 10.25.33?PM.png")![Screenshot 2024-08-24 at 10.25.51?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/343643i6D1A3D171E91622A/image-size/large?v=v2&px=999 "Screenshot 2024-08-24 at 10.25.51?PM.png")


author: Vikrant Yadav
body: Hi [@Andras M](/t5/user/viewprofilepage/user-id/4888833) [@Martin Hirsch](/t5/user/viewprofilepage/user-id/4829498) Checkout short video created for you : <https://www.youtube.com/watch?v=7OAquAcJaAo>


author: Andras M
body: Hi [@Vikrant Yadav](/t5/user/viewprofilepage/user-id/1801711) thank for your time and effort, now the notification works perfectly with the solution you provided. Simple, but effective. Cheers


author: Vikrant Yadav
body: Thanks [@Andras M](/t5/user/viewprofilepage/user-id/4888833) Glad to hear i am able to help you out!


author: Martin Hirsch
body: Thank you very much. One problem: I'm getting two posts in teams. One with the summary ane another one with the issue key. But i don't have the issue key in the web message. Only the summary and the description.


author: Vikrant Yadav
body: [@Martin Hirsch](/t5/user/viewprofilepage/user-id/4829498) Might be two workflows are running that's why two notifications are coming++.++

Kindly check number of workflows are enabled.


author: Martin Hirsch
body: You are right. Thank you very much.


author: Martin Hirsch

Tags: cloud

jira-cloud