# \<assign>

## \<assign> <a href="#assign" id="assign"></a>

The `<assign>` element assigns a value to a predefined variable.

### Attributes

<table><thead><tr><th width="222">Name</th><th width="143.33333333333331">Data type<select><option value="07bc2ffa63524ba9a2909e475e464b22" label="String" color="blue"></option><option value="120b6a4017084eadb25acf7eae3c4a2e" label="Integer" color="blue"></option><option value="99202b51e1d14812838fd9c1e783f75e" label="Boolean" color="blue"></option></select></th><th>Description</th></tr></thead><tbody><tr><td>name</td><td><span data-option="07bc2ffa63524ba9a2909e475e464b22">String</span></td><td>The name of the variable being assigned to.</td></tr><tr><td>expr</td><td><span data-option="07bc2ffa63524ba9a2909e475e464b22">String</span></td><td>An ECMAscript expression to be evaluated, the results of which are assigned to the named variable.</td></tr></tbody></table>

## Notes

The variable specified by the “name” attribute in the `<assign>` tag should be declared in a `<var>` tag first.

### Example

```markup
<?xml version="1.0"?>
<vxml version="2.0">
  <form>
    <!-- test_var is declared here -->
    <var name="test_var"/>
    <block>
      <!-- test_var must be declared before assigning it a value -->
      <assign name="test_var" expr="1234"/>
    </block>
    <block>
      <prompt>
        The test variable is set to <value expr="test_var"/>.
      </prompt>
    </block>
  </form>
</vxml>
```

The output of the above script would be:

> Computer: The test variable is set to twelve hundred thirty-four.

### Child Tags

None

### Parent Tags

[\<block>](/dev/voicexml/tags/block-tag.md), [\<catch>](/dev/voicexml/tags/catch-tag.md), [\<error>](/dev/voicexml/tags/error-tag.md), [\<filled>](/dev/voicexml/tags/filled-tag.md), [\<foreach>](/dev/voicexml/tags/foreach-tag.md), [\<help>](/dev/voicexml/tags/help-tag.md), [\<if>](/dev/voicexml/tags/if-tag.md), [\<noinput>](/dev/voicexml/tags/noinput-tag.md), [\<nomatch>](/dev/voicexml/tags/nomatch-tag.md)


---

# 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.plumvoice.com/dev/voicexml/tags/assign-tag.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.
