diff --git a/assets/tutorials/helmet/trigger.png b/assets/tutorials/helmet/trigger.png new file mode 100644 index 0000000000..63936251f7 Binary files /dev/null and b/assets/tutorials/helmet/trigger.png differ diff --git a/docs/configure/triggers.md b/docs/configure/triggers.md index 69022cf9e6..7a134bc6b4 100644 --- a/docs/configure/triggers.md +++ b/docs/configure/triggers.md @@ -10,15 +10,15 @@ aliases: - /build/configure/triggers/ --- -Triggers allow you to trigger webhooks when certain types of data are sent from your machine to the cloud, or when the your machine parts connect to Viam. -For example, you can configure a trigger to send you a notification when your robot's sensor collects a new reading. -Viam provides the following trigger types depending on the event you want to trigger on: +Triggers allow you to send webhook requests or emails for the following events: - **Data has been synced to the cloud**: trigger when data from the machine is synced - **Part is online**: trigger continuously at a specified interval while the {{< glossary_tooltip term_id="part" text="machine part" >}} is online - **Part is offline**: trigger continuously at a specified interval while the machine part is offline - **Conditional data ingestion**: trigger any time data is captured from a specified component with a specified method and condition +For example, you can configure a trigger to send you a notification when your robot's sensor collects a new reading. + To configure a trigger: {{< tabs >}} @@ -65,7 +65,8 @@ You must [configure data capture](/services/data/capture-sync/) for your compone {{< tabs name="Notifications types" >}} {{% tab name="Webhooks" %}} -Replace the **URL** value with the URL of your cloud function or lambda. +Click **Add Webhook**. +Add the URL of your cloud function or lambda. Configure the time between notifications. ![The trigger configured with an example URL in the Viam app.](/build/configure/trigger-configured.png) @@ -73,10 +74,11 @@ Configure the time between notifications. {{% /tab %}} {{% tab name="Emails" %}} +Click **Add Email**. Add the email you wish to be notified whenever this trigger is triggered. Configure the time between notifications. -![The trigger configured with an example URL in the Viam app.](/build/configure/trigger-configured-email.png) +![The trigger configured with an example email in the Viam app.](/build/configure/trigger-configured-email.png) {{% /tab %}} {{< /tabs >}} diff --git a/docs/tutorials/projects/helmet.md b/docs/tutorials/projects/helmet.md index a27ec2d7fe..9a19c2ceb3 100644 --- a/docs/tutorials/projects/helmet.md +++ b/docs/tutorials/projects/helmet.md @@ -2,7 +2,7 @@ title: "Monitor Job Site Helmet Usage with Computer Vision" linkTitle: "Helmet Monitor" type: "docs" -description: "Get an email alert if people are not wearing hard hats." +description: "Use computer vision to detect problems such as people not wearing safety gear and get email alerts." videos: ["/tutorials/helmet/hardhat.webm", "/tutorials/helmet/hardhat.mp4"] images: ["/tutorials/helmet/hardhat.gif"] videoAlt: "A man without a hard hat is detected and labeled as No-Hardhat. Then he puts on a hard hat and a bounding box labeled Hardhat appears. He gives a thumbs-up to the camera." @@ -18,10 +18,12 @@ cost: 120 {{}} -We all know personal protective equipment (PPE) helps keep us safe, but sometimes we need a reminder to use it consistently. -Luckily, you can address this problem using Viam's integrated [data capture](/services/data/capture-sync/), [computer vision](/services/vision/), and [triggers](/configure/triggers/), along with a hard hat detection model. +Personal protective equipment (PPE) helps keep us safe, but sometimes we need a reminder to use it consistently. +If you want to monitor the usage of PPE equipment, you can address this problem using computer vision and a machine learning model that can detect if someone is wearing a hard. -By following this tutorial you will build a system to look out for you and your team, sending an email notification when someone isn't wearing a hard hat. +By following this tutorial you will build a system that can monitor camera feeds and detect situations that require review. +In other words, this system performs anomaly detection. +Whenever the system detects an anomaly, like someone not wearing a hard hat, it will send an email notification. {{}} @@ -248,13 +250,18 @@ Now that you have verified that the detector and data sync are working, modify y ## Set up email notifications -[Triggers](/configure/triggers/) allow you to trigger actions by sending an HTML request when a certain event happens. -In this case, you're going to set up a trigger to trigger a serverless function that sends you an email when an image of someone without a hard hat is uploaded to the cloud. +[Triggers](/configure/triggers/) allow you to send webhook requests or email notifications when certain events happen. -Before you configure a trigger on your machine, you need to create a serverless function for the trigger to call. +For example, you can set up a trigger to perform an action whenever an image of someone without a hard hat is uploaded to the cloud. + +You can set up the trigger with a serverless function which sends you a customized email or with Viam's built-in email alerts which sends a generic email letting you know that data has been synced. + +If you wish to use Viam's built-in email alerts, skip ahead to [configuring a trigger on your machine](#set-up-email-notifications). +To set up a serverless function, continue reading. ### Create a serverless function +Before you configure a trigger on your machine, you need to create a serverless function for the trigger to call. A serverless function is a simple script that is hosted by a service such as [Google Cloud Functions](https://cloud.google.com/functions) or [AWS Lambda](https://aws.amazon.com/pm/lambda). You don't need to host it on your machine; instead, it is always available and runs only when an event triggers it. @@ -411,36 +418,26 @@ Now you can test the script: ### Configure a trigger on your machine -Now it's time to configure a [trigger](/configure/triggers/) on your machine to trigger the email cloud function when a person is not wearing a hard hat. +Now it's time to configure a trigger so that you get an email when a person is not wearing a hard hat. Since you configured data to sync only when an image of a person without a hard hat is captured, configuring the trigger to trigger each time an image is synced to the cloud will produce the desired result. -Configure a trigger as follows: +Go to the **CONFIGURE** tab of your machine on the [Viam app](https://app.viam.com). +Click the **+** (Create) button in the left side menu and select **Trigger**. -1. Navigate to the **CONFIGURE** tab of your machine. - Select **JSON** mode in the left-hand menu. +Name the trigger and click **Create**. -2. Paste the following JSON template into your JSON config. - `"triggers"` is a top-level section like `"components"`, `"services"`, or any of the other config sections. +Select trigger **Type** as **Data has been synced to the cloud** and **Data Types** as **Binary (image)**. - ```json {class="line-numbers linkable-line-numbers"} - "triggers": [ - { - "url": "", - "event": { - "attributes": { - "data_types": ["binary"] - }, - "type": "part_data_ingested" - } - } - ] - ``` +{{}} -3. Replace the `url` value with your cloud function URL. - You can get this URL by copying it from the **TRIGGER** tab in the cloud function console. - Once you've done this, the `url` line should resemble, for example, `"url": "https://us-east1-example-string-123456.cloudfunctions.net/hat-email"`. +To configure notifications, either -4. Click **Save** in the top right corner of the screen to save your changes. +- add a webhook and enter the URL of your custom cloud function, if you created one +- add an email address to use Viam's built-in email notifications + +For both options also configure the time between notifications. + +Click **Save** in the top right corner of the screen to save your changes. ## Test the whole system