# Session

The session data is where we store the state of the interaction between the bot and a user. A session can span multiple conversations.

{% hint style="info" %}
The maximum size of the session is 10MB
{% endhint %}

We automatically delete the session data after 30 days of inactivity.  You can configure this value in the bot [data retention](data-retention) settings.

## Default session data

The following table shows the session fields that are available in all sessions.&#x20;

An easy way to preview this data is through the debugger in the 'test your bot' window.

### Read-only session data

The internal session data is accessible using `internal.[fieldName]` and should be treated as read-only. We have certain mechanism in place to prevent modifying it. If somehow you manage to change some fields, we will override the values.&#x20;

> [All the fields documented below are considered stable. If you see other fields at runtime you can use them at you own risk and they are subject to change at any time. They may be exceptions to this, so when in doubt, reach out to our support for clarification.](#user-content-fn-1)[^1]

| Field Name          | Value  | Description                                                                                                               |
| ------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------- |
| botId               | string | ID of the bot                                                                                                             |
| sessionId           | string | ID of the session                                                                                                         |
| version             | string | The version of the bot, can be either DRAFT or LIVE                                                                       |
| channel             | string | The channel of the session                                                                                                |
| user                | object | object containing information about the user                                                                              |
| preferredLanguage   | string | The preferred language of the user                                                                                        |
| locale              | string | The preferred locale of the user (for example, for date formatting)                                                       |
| nlp                 | object | An object containing data about the latest expression, and which intent and entities were detected, with which confidence |
| nlp.sentiment       | object | Shows the sentiment analysis score of the last user expression                                                            |
| currentDialogstate  | object | An object containing the name, id and type of the last bot dialog (or block) triggered                                    |
| previousDialogstate | object | <p>show the name, id and type of the previous bot dialog  (or </p><p>block)  triggered</p>                                |
| messageContent      | string | The content of the last message sent by the user.                                                                         |
| messageType         | string | The type of the last message sent by the user. One of `intro`, `postback`, `text` or `upload`                             |

#### Example internal session&#x20;

```json
{
   "botId":"1457",
   "sessionId":"emulator-f28feb19-9d00-426a-ac65-539d5e1d3a73",
   "version":"DRAFT",
   "channel":"web",
   "user":{
      "firstName":"Guest"
   },
   "preferredLanguage":"en",
   "locale":"en-us",
   "nlp":{
      "expression":"hi",
      "intent":{
         "name":"Greeting",
         "score":1
      },
      "entities":[
         0
      ],
      "intents":[
         {
            "name":"Greeting",
            "score":1
         }
      ],
      "sentiment":{
         "name":"positive",
         "score":0.5183199216644359
   }
   "currentDialogstate":{
      "name":"introduction",
      "id":"25b838ca-0fea-4b97-b91e-31bd8d932cf9",
      "type":"MESSAGE"
   }
   "previousDialogstate":{
      "name":"introduction",
      "id":"25b838ca-0fea-4b97-b91e-31bd8d932cf9",
      "type":"MESSAGE"
   }
}
```

### User-changeable session data

The builder of the bot can create and save [variables](../navigation/settings/secure-variables-gdpr) to the user session. This data can be created by the bot through a conversation, or retrieved through an API call. Objects, as well as strings and other types of values can be saved to the user session.

[^1]: 
