| Description | This article describes how to configure a FortiGate to execute CLI commands on a schedule (e.g., every hour) and automatically send the command output to a Microsoft Teams channel via webhook. This method is useful for routine monitoring or diagnostics, such as routing tables, VPN status, or system resources without logging in each time. |
| Solution | To send a notification to MS Teams, FortiGate needs to have an incoming webhook connector address. Refer to: Create Incoming Webhooks While creating the incoming webhook, please provide FortiGate hostname as a name to get a notification with a specific device hostname. For example: The hostname of the FortiGate used in this article is 'LAB _FGT', so the Incoming Webhook connector name is set to 'LAB _FGT'.  FortiGate Configuration: Create a Scheduled Trigger in FortiGate GUI. - Go to Security Fabric -> Automation -> Trigger.
- Select 'Create New' and name it (e.g., Hourly).
- Under Schedule, choose Frequency as 'Hourly' or 'Daily,' etc.
- Set the interval as needed.
 Create CLI Script Action - In the same Automation Stitch, click “Create New”.
- Select CLI Script.
- Name it (e.g., Monitoring).
- Add the command(s) to run, e.g.: 'diagnose sys sdwan health-check'.
 Create Webhook Action to Send Output to Teams - In the same stitch, select 'Create New' again.
- Select Microsoft Teams Notification.
- Name it (e.g., Teams notification).
- Paste the Teams Webhook URL into the URI field.
- Modify the message as 'Text” as “%%results%%:'
- Or choose JSON and customize the format
- Eg: { "text": "FortiGate CLI Report:\n\n${%%results%%:}" }
 Stitch the Trigger and Actions: - In the Same Stitch, select 'Create New' again.
- Name it ( eg, Teams Notifications-Monitoring)
- Select the created Trigger.
- Select the CLI Command as 1st action.
- Select the Teams Notification as 2nd action.
- Select 'Ok. '
 Result: Now, every hour (or configured interval), FortiGate will: - Run the CLI commands configured.
- Automatically post the output to Teams channel.
Output:
 |