Quickstart using the Google Cloud Console

This quickstart shows you how to create, deploy, and execute your first workflow using the Cloud Console. The sample workflow sends a request to a sample API and then uses the response to create and send a request to a public API. The workflow returns the second API's response.

Before you begin

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. In the Google Cloud Console, on the project selector page, select or create a Google Cloud project.

    Go to the project selector page

  3. Make sure that billing is enabled for your Cloud project. Learn how to confirm that billing is enabled for your project.

  4. Enable the Workflows API.

    Enable the Workflows API
  5. In the Cloud Console, go to the Service accounts page.

    Go to the Create Service Account page
  6. Select Create service account.
  7. In the Service account name field, enter a name.
  8. Click Create.
  9. From the Role list, select Logging >Logs Writer.

    Note: The Role field authorizes your service account to access resources. To send logs to Cloud Logging, assign the roles/logging.logWriter role. If you are developing a production app, always grant the least permissive roles possible. For more information, see granting roles to service accounts. For a list of Workflows roles, see the Access control reference.
  10. Click Continue.
  11. Click Done.

Create and deploy a workflow

  1. To create a new workflow, open the Workflows page in the Google Cloud Console:
    Go to the Workflows page

  2. On the Workflows page in the console, select Create.

  3. Enter a name for the new workflow, such as myFirstWorkflow. The name can contain letters, numbers, underscores, and hyphens. It must start with a letter and end with a number or letter.

  4. Choose us-central1 for the region.

  5. Select the service account you created earlier for service account.

  6. Select Next.

  7. In the workflow editor, copy and paste the following workflow:

    YAML

    - getCurrentTime:
        call: http.get
        args:
          url: https://us-central1-workflowsample.cloudfunctions.net/datetime
        result: currentTime
    - readWikipedia:
        call: http.get
        args:
          url: https://en.wikipedia.org/w/api.php
          query:
            action: opensearch
            search: ${currentTime.body.dayOfTheWeek}
        result: wikiResult
    - returnResult:
        return: ${wikiResult.body[1]}

    JSON

    [
      {
        "getCurrentTime": {
          "call": "http.get",
          "args": {
            "url": "https://us-central1-workflowsample.cloudfunctions.net/datetime"
          },
          "result": "currentTime"
        }
      },
      {
        "readWikipedia": {
          "call": "http.get",
          "args": {
            "url": "https://en.wikipedia.org/w/api.php",
            "query": {
              "action": "opensearch",
              "search": "${currentTime.body.dayOfTheWeek}"
            }
          },
          "result": "wikiResult"
        }
      },
      {
        "returnResult": {
          "return": "${wikiResult.body[1]}"
        }
      }
    ]

    This workflow makes a call to a sample API to get the current date. It takes the day of the week from that response and passes it to the Wikipedia API, where it searches for relevant articles on Wikipedia about the current day of the week.

  8. Select Deploy.

Execute the workflow

Now that your workflow has been successfully deployed, we can execute it for the first time. After deploying the workflow, you'll be taken to its Details page:

Workflow details page

To execute the workflow:

  1. On the Workflows details page, select Execute.

  2. On the Execute workflow page, select Execute.

  3. View your workflow's results in the Output pane:

    Workflows quickstart output

You deployed and executed your first workflow!

Clean up

To avoid incurring charges to your Google Cloud account for the resources used in this quickstart, follow these steps.

  1. Go to the Workflows page in the Cloud Console.
    Workflows

  2. Select the Delete button.

  3. In the prompt that appears, enter the name of the workflow.

  4. Select Delete.

What's next