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

# State Nodes

> Persist data on contacts and conversations in Tedro workflows.

# State Nodes

State nodes allow your workflow to persist data that survives beyond a single run. Use them to build up contact profiles, track conversation progress, and store information for use in future interactions.

***

## state.set\_field

**Persist a field value on a contact or conversation.**

The Set Field node writes a key-value pair to either the contact record or the current conversation. This data is available in subsequent workflow runs and can be used in variable substitution, Switch node conditions, and AI context.

### Configuration

| Option      | Type   | Required | Description                                                                                            |
| ----------- | ------ | -------- | ------------------------------------------------------------------------------------------------------ |
| `target`    | string | Yes      | Where to store the field: `contact` or `conversation`                                                  |
| `fieldName` | string | Yes      | The field name (key). Use descriptive names like `language`, `purchase_intent_score`, `last_topic`     |
| `value`     | string | Yes      | The value to set. Can be a static string or a context expression referencing data from the current run |

### Value Expressions

The value field supports both static values and dynamic expressions:

```
# Static value
language: "en"

# From AI Router output
intent: {{router.category}}

# From message content
last_message: {{message.text}}
```

### Outputs

| Output        | Type   | Description                 |
| ------------- | ------ | --------------------------- |
| `field.name`  | string | The field name that was set |
| `field.value` | string | The value that was written  |

### Connections

* **Inputs**: Single input handle from the previous node
* **Outputs**: Single output handle for chaining additional actions

### Use Cases

**Tag a contact with their detected language:**
After an AI Router classifies the message language, set `contact.language` to the detected language code. Future workflows can use this field to respond in the correct language.

**Store a purchase intent score:**
After an AI Respond node analyzes the conversation, set `contact.purchase_intent_score` to a numeric value. Your CRM integration or export can use this for lead prioritization.

**Track conversation topic:**
Set `conversation.last_topic` to the current topic (e.g., "billing", "returns"). If the customer messages again, the AI can reference this field to maintain continuity.

**Record opt-in preferences:**
Set `contact.newsletter_opted_in` to "true" when a customer explicitly agrees to receive updates. Use this field in Switch node conditions to gate template message sends.

<Note>
  Contact fields persist across all conversations and workflow runs for that contact. Conversation fields are scoped to the specific conversation thread. Choose the appropriate target based on whether the data should be contact-wide or conversation-specific.
</Note>
