[Yandex Cloud documentation](../../index.md) > [Yandex Serverless Integrations](../index.md) > [Getting started](index.md) > Workflows

# Getting started with Workflows

{% note info %}

Workflows is at the [Preview](../../overview/concepts/launch-stages.md) stage.

{% endnote %}

Using this tutorial, you will create and run a [workflow](../concepts/workflows/workflow.md). During the execution of the workflow, the [Yandex Cloud Functions](../../functions/index.md) [functions](../../functions/concepts/function.md) will be called.


## Getting started {#before-you-begin}

To get started in Yandex Cloud:
1. Log in to the [management console](https://console.yandex.cloud). If not signed up yet, navigate to the management console and follow the on-screen instructions.
1. On the [**Yandex Cloud Billing**](https://center.yandex.cloud/billing/accounts) page, make sure you have a [billing account](../../billing/concepts/billing-account.md) linked and its [status](../../billing/concepts/billing-account-statuses.md) is `ACTIVE` or `TRIAL_ACTIVE`. If you do not have a billing account yet, [create one](../../billing/quickstart/index.md#create_billing_account).
1. If you do not have a [folder](../../resource-manager/concepts/resources-hierarchy.md#folder) yet, [create one](../../resource-manager/operations/folder/create.md).


## Create a service account {#create-sa}

{% list tabs group=instructions %}

- Management console {#console}

    1. In the [management console](https://console.yandex.cloud), select the [folder](../../resource-manager/concepts/resources-hierarchy.md#folder) for your [service account](../../iam/concepts/users/service-accounts.md).
    1. Navigate to **Identity and Access Management**.
    1. Click **Create service account**.
    1. Name the [service account](../../iam/concepts/users/service-accounts.md): `sa-for-function`.
    1. Click ![image](../../_assets/console-icons/plus.svg) **Add role** and select [`functions.functionInvoker`](../../iam/concepts/access-control/roles.md).
    1. Click **Create**. 

{% endlist %}


## Create a function to filter data {#create-filter-function}

{% list tabs group=instructions %}

- Management console {#console}

    1. In the [management console](https://console.yandex.cloud), select the folder to create your function in.
    1. Navigate to **Cloud Functions**.
    1. Create a function:
        1. In the top-right corner, click **Create function**.
        1. Enter the function name: `filter-function`.
        1. Click **Create**.
    1. Create a function version:
        1. In the **Editor** window that opens, select `Node.js 22`.
        1. Disable **Add files with code examples**.
        1. Click **Continue**.
        1. Create a file named `index.js` and add the following code into it:
            ```js
            module.exports.handler = async function (data, context) {
                return {
                    id: data.id,
                    name: data.name,
                    email: data.email,
                };
            };
            ```
        1. Under **Parameters**, specify the following in the field:
            * **Entry point**: `index.handler`
            * **Service account**: `sa-for-function`
        1. Click **Save changes**.

{% endlist %}


## Create a function to return email addresses {#create-return-function}

{% list tabs group=instructions %}

- Management console {#console}

    1. In the [management console](https://console.yandex.cloud), select the folder to create your function in.
    1. Navigate to **Cloud Functions**.
    1. Create a function:
        1. In the top-right corner, click **Create function**.
        1. Enter the function name: `return-function`.
        1. Click **Create**.
    1. Create a function version:
        1. In the **Editor** window that opens, select `Node.js 22`.
        1. Disable **Add files with code examples**.
        1. Click **Continue**.
        1. Create a file named `index.js` and add the following code into it:
            ```js
            module.exports.handler = async function (data, context) {
                return {
                    result: "OK",
                    emails: data.loaded_users.map(p => p.email)
                };
            };
            ```
        1. Under **Parameters**, specify the following in the field:
            * **Entry point**: `index.handler`
            * **Service account**: `sa-for-function`
        1. Click **Save changes**.

{% endlist %}


## Create a workflow {#create-workflow}

{% list tabs group=instructions %}

- Management console {#console}

    1. In the [management console](https://console.yandex.cloud), select the folder where you want to create a workflow.
    1. Navigate to **Serverless Integrations**.
    1. In the left-hand panel, select ![GraphNode](../../_assets/console-icons/graph-node.svg) **Workflows**.
    1. In the top-right corner, click **Create workflow**.
    1. In the **YaML specification** field, add the specification below. In the `functionId` field:
        * In line 39, step `process_user_transform_info`, specify the `filter-function` ID.
        * In line 44, step `upload_users`, specify the `return-function` ID.

        ```yaml
        yawl: "0.1"
        start: get_users
        defaultRetryPolicy:
          maxDelay: 10s
          retryCount: 2
          errorList:
            - STEP_QUOTA_EXCEEDED
        steps:
          get_users:
            httpCall:
              url: 'https://jsonplaceholder.typicode.com/\(.resource_type)'
              method: GET
              headers: {}
              query: {}
              output: '\({loaded_users: .})'
              next: process_users
          process_users:
            foreach:
              input: \(.loaded_users)
              output: '\({loaded_users: .})'
              next: upload_users
              do:
                start: process_user_get_info
                steps:
                  process_user_get_info:
                    httpCall:
                      url: https://jsonplaceholder.typicode.com/users/\(.id)
                      method: GET
                      headers: {}
                      query: {}
                      next: process_user_transform_info
                      output: '\({user: .})'
                      retryPolicy:
                        retryCount: 2
                        errorList:
                          - HTTP_CALL_500
                  process_user_transform_info:
                    functionCall:
                      functionId: <function_ID>
          upload_users:
            functionCall:
              functionId: "<function_ID>"
              input: '\({loaded_users, resource_type})'
        ```
    1. Expand **Additional parameters**:
    1. In the **Name** field, enter the workflow name.
    1. In the **Service account** field, select `sa-for-function`.
    1. Click **Create**.

{% endlist %}


## Run the workflow {#execute-workflow}

{% list tabs group=instructions %}

- Management console {#console}

    1. Select a workflow.
    1. In the top-right corner, click ![triangle-right](../../_assets/console-icons/triangle-right.svg) **Execute**.
    1. Enter input data in JSON format and click **Execute**.

        Input data in JSON format:

        ```json
        {
          "resource_type": "users"
        }
        ```

    1. When the workflow status changes from `Running` to `Completed`, the following JSON formatted result will appear in the **Output data** section:
        ```json
        {
          "result": "OK",
          "emails": [
            "Sincere@april.biz",
            "Shanna@melissa.tv",
            "Nathan@yesenia.net",
            "Julianne.OConner@kory.org",
            "Lucio_Hettinger@annie.ca",
            "Karley_Dach@jasper.info",
            "Telly.Hoeger@billy.biz",
            "Sherwood@rosamond.me",
            "Chaim_McDermott@dana.io",
            "Rey.Padberg@karina.biz"
          ]
        }
        ```

{% endlist %}


## What's next {#what-is-next}

* [Check out another example of a workflow specification](../concepts/workflows/yawl/index.md#spec-example)
* [Read about the Workflows concepts](../concepts/workflows/workflow.md)