【Scheduler】Sending message to Microsoft Teams (Webhook:Advanced)

In the previous post, [【Scheduler】Sending message to Microsoft Teams (Webhook: Basic)](https://qiita.com/Miki_Yokohata/items/a3d30904ebfe0686a724) I tried sending a simple plain text, but this time I will try sending a message using a format other than plain text.

Duplicate the previously created scheduler task. You can create a duplicate by selecting the task to be duplicated and selecting `Clone` from the right-click menu.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/298e0c1c-6ae0-dca8-9fb2-adc03e907eb5.png)
Open the cloned task and start editing.
### Using query results as part of the message ###
Start by defining a query and using the returned values in a message.
Go to the `Actions` tab and use the `New` icon to add a **Query** action. Define the query with the `Edit Query` button.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/4941b1bf-0cdc-f341-4501-710f0d7f0b26.png)
Define a query that simply returns the total number of reports created by our system's publishers. Save with the `OK` button.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/41d6a7fe-d1f2-7f91-06e6-a5ffb76aba9c.png)
Use the `task parameters` option. A task parameter with the same name can be created by specifying the `output name` defined in the query.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/79a30b9c-3b2c-3bb2-79d5-b92a18908c33.png)
Go to the existing `Microsoft Teams` action. Leave the previous Webhook settings as they are, set the `subject` to **Test2**, and paste the following content into the `message`. Also turn on the `HTML` option. I am using the task parameter {_Task.Param.<font color=red>ReportTotal</font>} created by the query task. Below that is a link to a normal web page.
```
<p style="font-family:verdana">The total number of Web Report is {_Task.Param.ReportTotal}</p>

<a href='https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook'>Reference</a>
```
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/5b317715-a177-9281-bb14-2febf34bc496.png)
Now it's completed. Save the task with the `OK` button.
With this task selected from the scheduler task list, select `Execute` from the right-click menu to manually run the task.
If it finished successfully, check the message in Teams.
Both the query result and the link are successfully delivered as a message.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/791db244-cb7a-b3a9-724b-509cf05415c5.png)
### Using advanced configuration methods ###
This method defines a message in JSON format.
Reopen the previous task and go to the `Actions` tab. Select the **Microsoft Teams** action you created and click the `Copy Row` icon. The **Microsoft Teams action** will be duplicated.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/51d4fcfb-fae1-467f-939f-3bf4891645ca.png)
Open the cloned action and now specify the `Advanced`  method.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/0afee422-7f89-6be2-1931-fc90f4e2145a.png)
Enter your message in the `POST Content` field in the following format:
```
{
        "@context": "https://schema.org/extensions",
        "@type": "MessageCard",
        "themeColor": "0072C6",
        "title": "Test by Miki - Ignore this",
        "text": "This is a test message<br><a href='https://learn.microsoft.com/en-au/outlook/actionable-messages/send-via-connectors'>Reference</a>"
 }
```
Save the task with the `OK` button, select `Execute` from the right-click menu, and try running the task manually.
If it finished successfully, check the message in Teams. Since there are two **Microsoft Teams** actions defined, you should receive two messages.
It's excellent!!:thumbsup:
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2530698/5c2fbda7-f1f4-47a8-0237-83dcfd828334.png)

Thank you.