# Shadow Variables

VoiceXML uses standard variable systems. This means that Fuse does too, because it is built on VoiceXML. Standard variable systems allow users to create their own variables and manipulate them directly.

## Global Shadow Variables

Fuse allow access to global session variables that contains information about the current call. The *session* variable is a complex object that contains properties. Sometimes those properties have properties of their own.

Because these variables are global variables, there will be no need to use the `$` notation to access them.

In Fuse, users might want to access the following session properties:

| Global Variable                         | Explanation                                                                                                                                                       |
| --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| session.connection.ani                  | Caller's number, the phone number where the call was made from                                                                                                    |
| session.connection.dnis                 | Dialed number for this call. This is useful for applications that have multiple number deployments and would need to identify which number the caller has dialed. |
| session.connection.callee\_type         | Only for outbound calls, see [Callee Type Detection](https://docs.plumvoice.com/fuse/outbound#callee-type-detection)                                              |
| session.id                              | Unique ID for this call                                                                                                                                           |
| session.name                            | Name of the current active Fuse application                                                                                                                       |
| session.connection.protocol.sip.headers | only for SIP-in calls                                                                                                                                             |

## Last Result Shadow Variables

When collecting input or interacting with a REST web service, information often exists in addition to the “response” data that users may want to access. Shadow variables allow users to access this additional data.

Adding a `$` symbol to the end of a variable, automatically creates a shadow variable for that variable. The shadow variable will contain different member variables depending on the type of input or web service it is being used with. For example, with an input `credit_card` you can determine the confidence of the grammar engine match by accessing `credit_card$.confidence`.

This variable is filled in the case of both a match or a nomatch. `Lastresult$` allows users to get the list of all possible matches, not just the best match. In the event that speech input exists for the variable in use, `lastresult$` can also provide a recording of the utterance spoken by the user (for speech input).

Having access to this data, even in the “nomatch” case, allows users to send DTMF input off without requiring a match, or to send the utterance recording somewhere (perhaps to [transcription](https://docs.plumvoice.com/documentation/using-the-plum-voice-suite/how-to-guides/using-plums-transcription-api)).

Users can also access the “n-best” results if there were multiple matches by accessing `$lastresult[i]` where “i” represents the position in the list of matches (0 is the best match, 1 is second best, etc.).

The common `lastresult$` properties are (<https://www.w3.org/TR/voicexml20/#dml5.1.5>):

* `lastresult$.confidence`
* `lastresult$.utterance`
* `lastresult$.inputmode`
* `lastresult$.interpretation`
* `lastresult$.recording` (only for speech input)
* `lastresult$.length`
* `lastresult$[i].confidence`
* `lastresult$[i].utterance`
* `lastresult$[i].inputmode`
* `lastresult$[i].interpretation`

## Module Specific Shadow Variables

Some modules in Fuse have specific shadow variable associated with them.\
“name” below refers to the actual name of the module.

### **Call-Flow Modules**

The <img src="https://820663326-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M40QJ5NXmtM4utV6bD_%2F-M4u8_YcRziLXQiLsKMa%2F-M4u9_1rIyfqQ9Ly7uyd%2Ftransfer.svg?alt=media&#x26;token=f4d4527d-aa85-4bdb-99bf-06b2ec039751" alt="" data-size="line"> [Transfer module](https://docs.plumvoice.com/fuse/call-flow/transfer) provides a shadow variable: (<https://www.w3.org/TR/voicexml20/#dml2.3.7>)

* `name$.duration`

### **Input Modules**

For <img src="https://820663326-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M40QJ5NXmtM4utV6bD_%2F-M4u8_YcRziLXQiLsKMa%2F-M4u9_0qz7dhl2Ok4ige%2Finput.svg?alt=media&#x26;token=c44bb0fa-2f9a-4aa6-a463-a357efb93ad3" alt="" data-size="line"> [input modules](https://docs.plumvoice.com/fuse/input), a standard set of shadow variables exist (<https://www.w3.org/TR/voicexml20/#dml2.3.1>):

* `name$.utterance`
* `name$.inputmode`
* `name$.interpretation`
* `name$.confidence`

For the <img src="https://820663326-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M40QJ5NXmtM4utV6bD_%2F-M4u8_YcRziLXQiLsKMa%2F-M4u9_1SusPxpN_HpR2o%2Frecord.svg?alt=media&#x26;token=c39c0d4d-2f3f-4ea4-91a1-60add0431354" alt="" data-size="line"> [Record](https://docs.plumvoice.com/fuse/input/record) module, a slightly different set of shadow variables exist (<https://www.w3.org/TR/voicexml20/#dml2.3.6>):

* `name$.duration`
* `name$.size`
* `name$.termchar`
* `name$.maxtime`

### **Data Modules**

The <img src="https://820663326-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M40QJ5NXmtM4utV6bD_%2F-M4u8_YcRziLXQiLsKMa%2F-M4u9_1ajC7GIKRSWvr_%2Frest.svg?alt=media&#x26;token=61a7d6cf-4223-43b0-b1af-f2c11e6c7f1d" alt="" data-size="line"> [REST](https://docs.plumvoice.com/fuse/data/rest) web service module provides some custom shadow variables:

* `name$.http_code`
* `name$.headers` (object indexed by header name)
* `name$.raw_headers` (0-indexed array containing all header strings)
* `name$.error` (only in the event of an error)

### Integration Modules

{% hint style="info" %}
**NOTE:** Some of the following terms and concepts are specific to Google Dialogflow.
{% endhint %}

#### Dialogflow module

The <img src="https://820663326-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M40QJ5NXmtM4utV6bD_%2Fuploads%2FKHwxH1lkqNZet8yJko4I%2FUI-Module-icons_iconDialogflow.svg?alt=media&#x26;token=919b3751-e539-4277-ba62-8bb9e82aa37b" alt="" data-size="line"> [Dialogflow](https://docs.plumvoice.com/fuse/integration/dialogflow) module provides the following shadow variables for Dialogflow response details:

<table><thead><tr><th width="184.61275999215036">Shadow variable</th><th width="401.3933379130153">Returns</th><th data-hidden></th></tr></thead><tbody><tr><td><code>name$.query</code></td><td><code>string</code><br>End-user input received by Dialogflow.</td><td></td></tr><tr><td><code>name$.intent</code></td><td><code>string</code><br>Intent matched to the received end-user input.</td><td></td></tr><tr><td><code>name$.message</code></td><td><code>string</code><br>Text of the response spoken or displayed to the end-user based on the matched intent.</td><td></td></tr><tr><td><code>name$.entities</code></td><td><code>object</code><br>Entity types associated with the matched intent.</td><td></td></tr><tr><td><code>name$.confidence</code></td><td><code>integer</code><br>Confidence level for the name field.</td><td></td></tr><tr><td><code>name$.allRequiredParamsPresent</code></td><td><p><code>boolean</code><br>Returns <code>true</code> when:</p><ul><li>All required parameter values have been collected</li></ul><p>      OR</p><ul><li>The matched intent contains no required parameters.</li></ul><p></p><p>Returns <code>false</code> when:</p><ul><li>The matched intent has required parameters</li></ul><p>      AND</p><ul><li>One or more required parameter values have not been collected.</li></ul></td><td></td></tr></tbody></table>

#### DynamoDB module

Table data returned by a <img src="https://820663326-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M40QJ5NXmtM4utV6bD_%2Fuploads%2FuVkxorS3Q0aiLZCIuiJ0%2FUI-Module-icons_iconDynamoDB.svg?alt=media&#x26;token=f3fdfa3e-96a0-4da0-8ae7-d3bba490382d" alt="" data-size="line"> [DynamoDB](https://docs.plumvoice.com/fuse/variables/broken-reference) module is formatted in a zero-indexed array, which you can access through shadow variables. You can write these shadow variables by using the names of any column(s) returned and the module itself. The `$` symbol is not used here.

**Format:** `module_name[index_number].[column_name]`

**Example:** `CallerQuery[0].product_id`


---

# 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/fuse/variables/shadow-variables.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.
