- [JSON representation](https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/EventHandler#SCHEMA_REPRESENTATION)

An event handler specifies an `https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/EventHandler#FIELDS.event` that can be handled during a session. When the specified event happens, the following actions are taken in order:

- If there is a `https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/EventHandler#FIELDS.trigger_fulfillment` associated with the event, it will be called.
- If there is a `https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/EventHandler#FIELDS.target_page` associated with the event, the session will transition into the specified page.
- If there is a `https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/EventHandler#FIELDS.target_flow` associated with the event, the session will transition into the specified flow.

| JSON representation |
|---|
| ``` { "name": string, "event": string, "triggerFulfillment": { object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/Fulfillment`) }, // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "targetPage": string, "targetFlow": string, "targetPlaybook": string // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| `name` | `string` Output only. The unique identifier of this event handler. |
| `event` | `string` Required. The name of the event to handle. |
| `triggerFulfillment` | ``object (`https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/Fulfillment`)`` The fulfillment to call when the event occurs. Handling webhook errors with a fulfillment enabled with webhook could cause infinite loop. It is invalid to specify such fulfillment for a handler handling webhooks. |
| The target to transition to, either a page in the same host flow (the flow that owns this `https://docs.cloud.google.com/dialogflow/cx/docs/reference/rest/v3/TransitionRoute`), or another flow in the same agent. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `targetPage` | `string` The target page to transition to. Format: `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/flows/<FlowID>/pages/<PageID>`. |
| `targetFlow` | `string` The target flow to transition to. Format: `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/flows/<FlowID>`. |
| `targetPlaybook` | `string` The target playbook to transition to. Format: `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>`. |
| End of mutually exclusive fields. ||