> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognigy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# setState

<Warning>
  As of Cognigy.AI 2026.7.0, States are deprecated. The removal of States is planned for Cognigy.AI 2026.12.0. Before the removal, delete your States and retrain your NLU model so it no longer uses state-based Intent masking. For alternative approaches to control Intent recognition, use [Intent Conditions](/ai/platform-features/nlu/intents/conditions).
</Warning>

## Syntax

`setState(state)`

## Description

Updates the conversation State to a specified State. The State must be one of the States defined in the current Flow via **NLU > States**.

**Parameters:**

* `state`: `string` — one of the available States for the current Flow.

**Returns:** `void`

## Example

```js theme={null}
setState("collecting_name");
// User provides a name

setState("collecting_email");
// User provides an email

setState("validating_info");
thinkV2("Let me validate your information", {
  name: "John Doe",
  email: "john@example.com",
  timestamp: new Date().toISOString()
});

setState("registration_complete");
```
