# Basic Examples

## Customer Banking Transactions

{% code lineNumbers="true" %}

````json
{
  "id": "bankingtransactions",
  "name": "Customer Banking Transactions Workflow",
  "version": "1.0",
  "specVersion": "0.8",
  "timeouts": {
    "workflowExecTimeout": {
      "duration": "PT1M"
    },
    "actionExecTimeout": "PT10S"
  },
  "autoRetries": true,
  "start": "ProcessTransactions",
  "states": [
    {
      "name": "ProcessTransactions",
      "type": "foreach",
      "inputCollection": "${ .customer.transactions }",
      "iterationParam": "${ .tx }",
      "mode": "parallel",
      "actions": [
        {
          "name": "Processing Action",
          "functionRef": "InvokeBankingService"
        }
      ],
      "end": true
    }
  ],
  "functions": [
    {
      "name": "InvokeBankingService",
      "type": "rest"
    },
    {
      "name": "QueryCustomerName",
      "type": "expression",
      "operation": "${ .customer.name }"
    },
    {
      "name": "QueryCustomerAge",
      "type": "expression",
      "operation": "${ .customer.age }"
    }
  ]
}

```
````

{% endcode %}

## Customer Application

{% code lineNumbers="true" %}

````json
{
  "id": "customerapplication",
  "name": "Customer Application Workflow",
  "version": "1.0",
  "timeouts": {
    "workflowExecTimeout": {
      "duration": "PT1M"
    },
    "actionExecTimeout": "PT10S"
  },
  "retries": [
    {
      "name": "WorkflowRetries",
      "delay": "PT3S",
      "maxAttempts": 10
    }
  ],
  "states": [
    {
      "name": "NewCustomerApplication",
      "type": "event",
      "onEvents": [
        {
          "eventRefs": ["NewApplicationEvent"],
          "actionMode": "parallel",
          "actions": [
            {
              "name": "Invoke Check Customer Info Function",
              "functionRef": "CheckCustomerInfo"
            },
            {
              "name": "Invoke Update Application Info Function",
              "functionRef": "UpdateApplicationInfo"
            }
          ]
        }
      ],
      "transition": "MakeApplicationDecision"
    },
    {
      "name": "MakeApplicationDecision",
      "type": "switch",
      "dataConditions": [
        {
          "condition": "${ .customer.age >= 20 }",
          "transition": "ApproveApplication"
        },
        {
          "condition": "${ .customer.age < 20 }",
          "transition": "RejectApplication"
        }
      ],
      "defaultCondition": {
        "transition": "RejectApplication"
      }
    },
    {
      "name": "ApproveApplication",
      "type": "operation",
      "actions": [
        {
          "name": "Invoke Approve Application Function",
          "functionRef": "ApproveApplication",
          "sleep": {
            "before": "PT1S"
          }
        }
      ],
      "end": true
    },
    {
      "name": "RejectApplication",
      "type": "operation",
      "actions": [
        {
          "name": "Invoke Reject Application Function",
          "functionRef": "RejectApplication",
          "sleep": {
            "before": "PT1S"
          }
        }
      ],
      "end": true
    }
  ],
  "functions": [
    {
      "name": "CheckCustomerInfo",
      "type": "rest"
    },
    {
      "name": "UpdateApplicationInfo",
      "type": "rest"
    },
    {
      "name": "ApproveApplication",
      "type": "rest"
    },
    {
      "name": "RejectApplication",
      "type": "rest"
    },
    {
      "name": "QueryCustomerName",
      "type": "expression",
      "operation": "${ .customer.name }"
    },
    {
      "name": "QueryCustomerAge",
      "type": "expression",
      "operation": "${ .customer.age }"
    }
  ],
  "events": [
    {
      "name": "NewApplicationEvent",
      "type": "com.fasterxml.jackson.databind.JsonNode",
      "source": "applicationsSource"
    }
  ]
}

```
````

{% endcode %}

## Applicant Processing

{% code lineNumbers="true" %}

````json
{
  "id": "applicantworkflow",
  "name": "Applicant Processing Workflow",
  "version": "1.0",
  "specVersion": "0.8",
  "timeouts": {
    "workflowExecTimeout": {
      "duration": "PT2M"
    },
    "actionExecTimeout": "PT10S"
  },
  "autoRetries": true,
  "states": [
    {
      "name": "ApproveApplicant",
      "type": "operation",
      "actions": [
        {
          "name": "approvalAction",
          "functionRef": {
            "refName": "approvalFunction",
            "arguments": {
              "customer": "${ .customer }"
            }
          }
        }
      ],
      "transition": "WaitForDecision"
    },
    {
      "name": "WaitForDecision",
      "type": "event",
      "onEvents": [
        {
          "eventRefs": ["CustomerDecision"]
        }
      ],
      "end": true
    }
  ],
  "functions": [
    {
      "name": "approvalFunction",
      "type": "custom",
      "operation": "approvalworkflow#ToApproveCustomer"
    }
  ],
  "events": [
    {
      "name": "CustomerDecision",
      "type": "com.fasterxml.jackson.databind.JsonNode",
      "source": "applicationsSource"
    }
  ]
}

```
````

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.a4b.vn/xflow/examples/basic-examples.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
