---
description: Step duration ~28 min
---

# Step 4. Watching Features

## Step 4.1: Email Confirmation

{% embed url="https://youtu.be/srYAF1imzho" %}
15:49
{% endembed %}

Set the default role `not authorised` for every new user (object from `WebUser`) and create a simple scenario:

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-Mb7MPb3sJCKEkLHbvY3%2F-MbA_EpiHSK-U1rRQbZt%2Fnew_user.jpg?alt=media\&token=8438193d-719c-4e74-944f-e316501d385e)

Add two data structures.

`ConfirmRequest` with the following fields:

* `user_id` — link to `WebUser`
* `code` — type of string
* Fields for sync [result processing](../../../web-pages/components/form#online-result-processing)
  * `is_success` type of boolean
  * `result_title` type of string
  * `result_text` type of string.

`CodeRequest` with the following fields:

* `user_id` — link to `WebUser`
* Fields for sync [result processing](../../../web-pages/components/form#online-result-processing):
  * `is_success` type of boolean
  * `result_title` type of string
  * `result_text` type of string.

Create a new web page called '**Watch features'** and add two [conditional sections](../../../web-pages/setting-up-pages-layout#conditional-sections-visibility):

* The first section is visible only for users with the `not confirmed` role and includes two forms:
  * Form for submitting `ConfirmRequest`
  * Form for submitting `CodeRequest`
* The second section is visible only for users with the `confirmed`role.

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-Mb7MPb3sJCKEkLHbvY3%2F-MbA_uDS2p-VoFma0Ykg%2Fsection.jpg?alt=media\&token=8364e1d3-8a9c-4ab6-96d0-0860350f9332)

The '`CodeRequest'`form triggers a scenario in sync mode, which generates and sends a code to the user. The code is then saved in the`WebUser` object.

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-Mb7MPb3sJCKEkLHbvY3%2F-MbAbCTW3e_uJdA3Lswi%2Fgenerste_code.jpg?alt=media\&token=2a873de0-b51b-4604-9c5a-2b942b047171)

The '`ConfirmRequest`' form compares the provided code with the one saved in the the '`WebUser'` object. If they match, the role '`not confirmed'` is removed, and the role '`confirmed'` is added to the '`role'` field in the '`WebUser'` object.

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-Mb7MPb3sJCKEkLHbvY3%2F-MbAbiRra4R3vqgUJm7_%2Fcode.jpg?alt=media\&token=af85ede7-8a47-4855-9901-af4b6c9bcf78)

## Step 4.2: Watching Features

{% embed url="https://youtu.be/FoRWMmOcn-g" %}
12:34
{% endembed %}

Create a new data structure called 'WatchRequest' with the following fields:

1. 'user\_id' – a link to 'WebUser.'
2. 'feature\_id' – a link to 'features.'
3. 'type' – a string type to store 'watch' or 'unwatch'."

Add a new field 'users\_watching\_ids' with the type 'arrayLink' to the 'Features' data structure.

Create a new API-endpoint and a new web-page named 'Watch features.' In the endpoint, set a filter 'users\_watching\_ids arrayContainsAny \{{id\}}' to select only the features where the user's ID is in 'users\_watching\_ids.'

Now, add two actions:

1. 'Watch' on the 'Upvote features' web-page.
2. 'Unwatch' on the 'Watch features' web-page.

Scenario for processing WatchRequest (can be either synchronous or regular)

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-MbAhEaCCUcyuQAconlb%2F-MbAli7EyQyxgXJbtwNT%2Fwatch.jpg?alt=media\&token=4777e769-acd1-425d-a3f3-f371d3d89e56)

Next, create a new scenario triggered by changes in the development\_status and request\_status fields of the feature object. This scenario sends objects from the users\_watching\_ids to the 'Notify users' scenario, passing the feature\_id as a parameter ([context variable](../../scenarios/using-variables/context-variables)).

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-MbAhEaCCUcyuQAconlb%2F-MbAmScZ3YmCOcOH5Eiq%2Fnotify.jpg?alt=media\&token=12d99cfd-d7e0-4231-92d3-ffbe275a959f)

That is it! Thank you for using Directual. You can find the Open Development Roadmap app among our free templates.
