Create a workflow by using the Google Cloud console

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


To follow step-by-step guidance for this task directly in the Google Cloud console, click Guide me :

Guide me


Before you begin

Security constraints defined by your organization might prevent you from completing the following steps. For troubleshooting information, see Develop applications in a constrained Google Cloud environment .

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project .

  4. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  5. Verify that billing is enabled for your Google Cloud project .

  6. Enable the Workflows API.

    Enable the Workflows API

  7. In the Google Cloud console, go to the Service Accountspage.

    Go to Service Accounts

  8. Select a project and then click Create service account.
  9. In the Service account namefield, enter a name, such as sa-name .
  10. Click Create and continue.
  11. To send logs to Cloud Logging, click the Select a rolefield and select Logging > Logs Writer .

    To learn more about service account roles and permissions, see Grant a workflow permission to access Google Cloud resources .

  12. Click Done.

Create and deploy a workflow

  1. In the Google Cloud console, go to the Workflowspage:

    Go to Workflows

  2. On the Workflowspage, click Create.

  3. Enter a name for the new workflow, such as myFirstWorkflow .

  4. Choose us-central1for the region.

  5. For service account, select the service account you created earlier.

  6. Select Next.

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

    YAML

      main 
     : 
      
     params 
     : 
      
     [ 
     input 
     ] 
      
     steps 
     : 
      
     - 
      
     checkSearchTermInInput 
     : 
      
     switch 
     : 
      
     - 
      
     condition 
     : 
      
     '${"searchTerm" 
      
     in 
      
     input}' 
      
     assign 
     : 
      
     - 
      
     searchTerm 
     : 
      
     '${input.searchTerm}' 
      
     next 
     : 
      
     readWikipedia 
      
     - 
      
     getLocation 
     : 
      
     call 
     : 
      
     sys.get_env 
      
     args 
     : 
      
     name 
     : 
      
     GOOGLE_CLOUD_LOCATION 
      
     result 
     : 
      
     location 
      
     - 
      
     setFromCallResult 
     : 
      
     assign 
     : 
      
     - 
      
     searchTerm 
     : 
      
     '${text.split(location, 
      
     "-")[0]}' 
      
     - 
      
     readWikipedia 
     : 
      
     call 
     : 
      
     http.get 
      
     args 
     : 
      
     url 
     : 
      
     'https://en.wikipedia.org/w/api.php' 
      
     query 
     : 
      
     action 
     : 
      
     opensearch 
      
     search 
     : 
      
     '${searchTerm}' 
      
     result 
     : 
      
     wikiResult 
      
     - 
      
     returnOutput 
     : 
      
     return 
     : 
      
     '${wikiResult.body[1]}' 
     
    

    JSON

      { 
      
     "main" 
     : 
      
     { 
      
     "params" 
     : 
      
     [ 
      
     "input" 
      
     ], 
      
     "steps" 
     : 
      
     [ 
      
     { 
      
     "checkSearchTermInInput" 
     : 
      
     { 
      
     "switch" 
     : 
      
     [ 
      
     { 
      
     "condition" 
     : 
      
     "${\"searchTerm\" in input}" 
     , 
      
     "assign" 
     : 
      
     [ 
      
     { 
      
     "searchTerm" 
     : 
      
     "${input.searchTerm}" 
      
     } 
      
     ], 
      
     "next" 
     : 
      
     "readWikipedia" 
      
     } 
      
     ] 
      
     } 
      
     }, 
      
     { 
      
     "getLocation" 
     : 
      
     { 
      
     "call" 
     : 
      
     "sys.get_env" 
     , 
      
     "args" 
     : 
      
     { 
      
     "name" 
     : 
      
     "GOOGLE_CLOUD_LOCATION" 
      
     }, 
      
     "result" 
     : 
      
     "location" 
      
     } 
      
     }, 
      
     { 
      
     "setFromCallResult" 
     : 
      
     { 
      
     "assign" 
     : 
      
     [ 
      
     { 
      
     "searchTerm" 
     : 
      
     "${text.split(location, \"-\")[0]}" 
      
     } 
      
     ] 
      
     } 
      
     }, 
      
     { 
      
     "readWikipedia" 
     : 
      
     { 
      
     "call" 
     : 
      
     "http.get" 
     , 
      
     "args" 
     : 
      
     { 
      
     "url" 
     : 
      
     "https://en.wikipedia.org/w/api.php" 
     , 
      
     "query" 
     : 
      
     { 
      
     "action" 
     : 
      
     "opensearch" 
     , 
      
     "search" 
     : 
      
     "${searchTerm}" 
      
     } 
      
     }, 
      
     "result" 
     : 
      
     "wikiResult" 
      
     } 
      
     }, 
      
     { 
      
     "returnOutput" 
     : 
      
     { 
      
     "return" 
     : 
      
     "${wikiResult.body[1]}" 
      
     } 
      
     } 
      
     ] 
      
     } 
     } 
     
    

    Unless you input your own search term, this workflow uses your Google Cloud location to construct a search term, which it passes to the Wikipedia API . A list of related Wikipedia articles is returned.

  8. Select Deploy.

Execute the workflow

Once your workflow has been successfully deployed, you can execute it for the first time. After deploying the workflow, you'll be taken to its Workflow detailspage.

  1. On the Workflow detailspage, click Execute.

  2. On the Execute workflowpage, click Execute.

  3. In the Outputpane, your workflow's results are displayed.

You've deployed and executed your first workflow!

Clean up

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

  1. In the Google Cloud console, go to the Workflowspage:

    Go to Workflows

  2. From the list of workflows, click a workflow to go to its Workflow detailspage.

  3. Click Delete.

  4. Type the name of the workflow and then click Confirm.

What's next

Design a Mobile Site
View Site in Mobile | Classic
Share by: