Getting Started with Service Calls and the Serverless Workflow

Posted on
{
  "id": "greeting",
  "version": "1.0",
  "specVersion": "0.8",
  "name": "Greeting workflow",
  "description": "JSON based greeting workflow",
  "start": "ChooseOnCountry",
  "functions": [
    {
      "name": "getGreetingFunction",
      "operation": "international-greeting-service.yml#getGreeting"
    }
  ],
  "states": [
    {
      "name": "ChooseOnCountry",
      "type": "switch",
      "dataConditions": [
        {
          "condition": "${ .country == "United States" }",
          "transition": "GreetInEnglish"
        },
        {
          "condition": "${ .country == "Spain" }",
          "transition": "GreetInSpanish"
        },
        {
          "condition": "${ .country == "Brazil" }",
          "transition": "GreetInPortuguese"
        }
      ],
      "defaultCondition": {
        "transition": "GreetInEnglish"
      }
    },
    {
      "name": "GreetInEnglish",
      "type": "inject",
      "data": {
        "language": "English"
      },
      "transition": "GetGreeting"
    },
    {
      "name": "GreetInSpanish",
      "type": "inject",
      "data": {
        "language": "Spanish"
      },
      "transition": "GetGreeting"
    },
    {
      "name": "GreetInPortuguese",
      "type": "inject",
      "data": {
        "language": "Portuguese"
      },
      "transition": "GetGreeting"
    },
    {
      "name": "GetGreeting",
      "type": "operation",
      "actions": [
        {
          "name": "getGreeting",
          "functionRef": {
            "refName": "getGreetingFunction",
            "arguments": {
                  "name": "${ .name }",
                  "language": "${ .language }"
              }
          }
        }
      ],
      "stateDataFilter": {
        "output": "${ {greeting: .greeting} }"
      },
      "end": true
    }
  ]
}

Leave a Reply

Your email address will not be published.