> For the complete documentation index, see [llms.txt](https://docs.a4b.vn/xflow/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.a4b.vn/xflow/developer-guide/workflow-states-reference/event-state.md).

# Event State

| Parameter       | Description                                                                                                                                                                                                  | Type              | Required                             |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------- | ------------------------------------ |
| name            | Unique State name                                                                                                                                                                                            | string            | yes                                  |
| type            | State type                                                                                                                                                                                                   | string            | yes                                  |
| exclusive       | If `true`, consuming one of the defined events causes its associated actions to be performed. If `false`, all of the defined events must be consumed in order for actions to be performed. Default is `true` | boolean           | no                                   |
| onEvents        | Define the events to be consumed and optional actions to be performed                                                                                                                                        | array             | yes                                  |
| timeouts        | State specific timeout settings                                                                                                                                                                              | object            | no                                   |
| stateDataFilter | State data filter definition                                                                                                                                                                                 | object            | no                                   |
| transition      | Next transition of the workflow after all the actions have been performed                                                                                                                                    | string or object  | yes (if `end` is not defined)        |
| onErrors        | States error handling definitions                                                                                                                                                                            | array             | no                                   |
| end             | Is this state an end state                                                                                                                                                                                   | boolean or object | yes (if `transition` is not defined) |
| compensatedBy   | Unique name of a workflow state which is responsible for compensation of this state                                                                                                                          | string            | no                                   |
| metadata        | Metadata information                                                                                                                                                                                         | object            | no                                   |

**Example:**

<table><thead><tr><th>JSON</th><th>YAML</th></tr></thead><tbody><tr><td><pre class="language-json"><code class="lang-json">{
"name": "monitor-vitals",
"type": "event",
"exclusive": true,
"onEvents": [{
        "eventRefs": ["high-body-temperature"],
        "actions": [{
            "functionRef": {
                "refName": "send-tylenol-order",
                "arguments": {
                    "patientid": "${ .patientId }"
                }
            }
        }]
    },
    {
        "eventRefs": ["high-blood-pressure"],
        "actions": [{
            "functionRef": {
                "refName": "call-nurse",
                "arguments": {
                    "patientid": "${ .patientId }"
                }
            }
        }]
    },
    {
        "eventRefs": ["high-respiration-rate"],
        "actions": [{
            "functionRef": {
                "refName": "call-pulmonologist",
                "arguments": {
                    "patientid": "${ .patientId }"
                }
            }
        }]
    }
],
"end": {
    "terminate": true
}
}
</code></pre></td><td><pre class="language-yaml"><code class="lang-yaml">name: monitor-vitals
type: event
exclusive: true
onEvents:
- eventRefs:
  - high-body-temperature
  actions:
  - functionRef:
      refName: send-tylenol-order
      arguments:
        patientid: "${ .patientId }"
- eventRefs:
  - high-blood-pressure
  actions:
  - functionRef:
      refName: call-nurse
      arguments:
        patientid: "${ .patientId }"
- eventRefs:
  - high-respiration-rate
  actions:
  - functionRef:
      refName: call-pulmonologist
      arguments:
        patientid: "${ .patientId }"
end:
  terminate: true
</code></pre></td></tr></tbody></table>

Event states await one or more events and perform actions when they are received. If defined as the workflow starting state, the event state definition controls when the workflow instances should be created.

The `exclusive` property determines if the state should wait for any of the defined events in the `onEvents` array, or if all defined events must be present for their associated actions to be performed.

Following two figures illustrate the `exclusive` property:

If the Event state in this case is a workflow starting state, the occurrence of *any* of the defined events would start a new workflow instance.

If the Event state in this case is a workflow starting state, the occurrence of *all* defined events would start a new workflow instance.

In order to consider only events that are related to each other, we need to set the `correlation` property in the workflow events definitions. This allows us to set up event correlation rules against the events extension context attributes.

If the Event state is not a workflow starting state, the `timeout` property can be used to define the time duration from the invocation of the event state. If the defined event, or events have not been received during this time, the state should transition to the next state or can end the workflow execution (if it is an end state).

The `timeouts` property can be used to define state specific timeout settings. Event states can define the `stateExecTimeout`, `actionExecTimeout`, and `eventTimeout` properties. For more information about Event state specific event timeout settings reference this section. For more information about workflow timeouts reference the Workflow Timeouts section.

Note that `transition` and `end` properties are mutually exclusive, meaning that you cannot define both of them at the same time.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/developer-guide/workflow-states-reference/event-state.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.
