# Overview

Airkit allows you to collect, use, modify, and remit data.

### What is Data?

Data is information that can be stored or used in your application. Data in Airkit has many different [data types](../variable-data-types/data-types-overview). Data can be simple types like [Text](../variable-data-types/the-text-variable-data-type) or [Number](../variable-data-types/the-number-variable-data-type), complex types like [Currency](../variable-data-types/the-currency-variable-data-type) or [Datetime](../variable-data-types/the-datetime-variable-data-type), or objects with a customized structure, such as [AirData App Objects](airdata/airdata-app-objects) or [Custom Data Types](../variable-data-types/custom-data-types).

Data can be collected from a user or stored in App and used as a configuration.

### 3 Ways To Store & Access Data

#### 1) Variable & Journey State

Variables are one way to store and access Data. Variables can be defined at different scopes to have different availability throughout an application. The data held in a variable reference can be changed throughout the lifetime of the app based upon events and actions.&#x20;

**Defining Variables in Namespaces and Scopes**

Namespaces refer to regions where we can store data. Scopes are how we access variables in each of the regions. For a detailed understanding, please check out this document on [variable scopes](variable-scopes). There are several different variable scopes for working with data. Some of them include:

**Session -** accessible anywhere throughout the app builder and journey builder. They are tied to a specific user's journey.

```javascript
session.first_name
```

Defining variables at the session level happens in [Journey Builder](../studio/builder-bar/journey-builder). Click on the canvas and the inspector will show available session scoped events.

![organizing info](https://a01-support.airkit.com/working-with-data/sessionVariablegif.gif)

\*\*ActivityGroup -\*\*accessible to any web page, action, or event within a specific [Web Flow](../studio/web-flows).

```javascript
activityGroup.first_name
```

To create a variable on a _Web Flow_, go to [App Builder](../studio/builder-bar/web-builder) and select a _Web Flow_ in the _Tree_. In the _Inspector_ under the _Variables_ section, there is a list of available _ActivityGroup_ scoped variables and a button to add new variables.

**Activity -** accessible to any event or control on a given web page.

```javascript
activity.first_name
```

To create a variable on a _Web Page_, go to [App Builder](../studio/builder-bar/web-builder) and select the _Web Page_ from the _Tree_. In the _Inspector_ under the _Variables_ section, there is a list of available _Activity_ scoped variables and a button to add new variables.

When referring to a variable without a scope in a _Web Flow,_ the runtime will attempt to find the variable in the most specific level and work up the chain, checking in **activity**, then **activityGroup**, then in **session**. It is possible to have variables named the same name in multiple scopes so it best to be specific when referring to your variables.

**Accessing the Data**

Defined data can be used in expression editors throughout the experience. In this case, the **activityGroup** variable **activity\_group\_name** is used to set the text for a label.

![organizing info](https://a01-support.airkit.com/working-with-data/ExpressionEditorText.png)

Updating values in variables can be done through [Set Variable Action](../actions/the-set-variable-action) on an action or event. This action can happen when a user takes an action, such as entering data into a form, clicking on a button, or responding to a text or voice prompt. Because this action uses an expression editor, Airscript can be used with properly scoped variables in updating variable values.

#### 2) Storing and Looking Up Records with AirData

AirData is a datastore tied to an app's profile where records can be stored for collection or retrieval. Use [Data Flows](../studio/data-flows) to look up and store your records into [AirData App Objects](airdata/airdata-app-objects). Airkit Studio has a bunch of ways to work with data stored in AirData.

**Seeing AirData in Data Builder**

The data stored in AirData can be viewed in the [Data Builder](../studio/builder-bar/data-builder). Selecting an object in the _Tree_ will show you the data already in the AirData Table.

![AirDataTable.png](https://a01-support.airkit.com/working-with-data/AirDataTable.png)

Clicking into a table cell will allow modification of data. Once a row has modified data, it will highlight in a light yellow. Changes will be committed on the next save. Add new rows by clicking on the cell to the right of the _Ne&#x77;_&#x74;ext. New rows are highlighted in light green. Just like modified rows, changes will be committed on the next save. Clicking the trash can at the left of a row will mark the row for deletion on the next save.

**Retrieving Data with Data Flows**

Data from AirData can be accessed through [Data Flows](../studio/data-flows) in [Connection Builder](../studio/builder-bar/connection-builder). To retrieve data from the above table, create a new Data Flow in Connection Builder. Select [AirData Request Data Operation](../data-operations/airdata-request-data-operation) from the dropdown for the first [Data Operation](../data-operations/data-operation-overview). The above AirData App Object is named **Teacher**, so select that from the dropdown.

![organizing info](https://a01-support.airkit.com/working-with-data/AirDataRunResults.png)

Clicking Play on the Data Operation will return the query results from the AirData table. In the picture above, there were 5 teachers in the **Teachers** AirData table. Returning the entire response is possible at this point, but it is also possible to filter out the results by creating another Data Operation of type [Transform](../data-operations/the-transform-data-operation). Writing something simple like:

```javascript
objectService.results
```

will return only the resulting array. Returning the result of the transform will return a [List](../variable-data-types/the-list-data-type) of **Teacher** Objects. In addition, additional filtering of the list can be done in the Transform using Airscript's [Query Expression Syntax](../airscript/filtering-data-using-query-expression) to pull out all teachers who have been teaching for at least five years.

```javascript
FROM teacher  
IN objectService.results  
WHERE teacher.years_teaching > 5  
SELECT teacher
```

The result of this transform would be all of the teachers who have a value of **years\_teaching** greater than five.

**Using Datastores**

AirData is stored in [Datastores](datastores). Datastores are collections of AirData that are kept in a specific environment. Different [Profiles](../building-apps/publishing/profiles-and-deployment-settings) can use different _Datastores_. Each datastore will have its own version of AirData. Create a clone of a _Datastore,_ which is useful when setting up environments for testing. When an app is created, a _Datastore_ is created with it. Switching the _Datastore_ can be done in [Configuration Builder](../studio/builder-bar/configuration-builder).

#### 3) External Systems of Record

External system data can be retrieved, modified, and updated through [Connection Builder](../studio/builder-bar/connection-builder). This data can be used throughout your App. Our [Data Flows](../studio/data-flows) can be used to fetch data from any HTTP API. Once data is ingested into the App through the connection it can be treated like any other [Variable Data Type](../variable-data-types/data-types-overview). For detailed instructions on how to get external data, check out [this article](connecting-to-external-systems).

### Using & Transforming Data

There are two main categories of data in the Studio. Data that needs to be gathered from a user and data that needs to be displayed. Gathering data is about creating [Forms and Agreements](https://docs.airkit.ai/?q=working-with-forms-and-agreements). When we create a [Text Input](../web-controls/text-input-web-control) on a \*Web Page,\*Airkit automatically creates a data binding to a text variable on the page. This variable can be displayed on the existing paged, passed to an action like a Data Connection, or an Event. The data can also be passed to future Web Pages in the journey:

![organizing info](https://a01-support.airkit.com/working-with-data/GoodMorning1.png) ![organizing info](https://a01-support.airkit.com/working-with-data/GoodMorning2.png)

In this example, the text is retrieved from the user and passed to the subsequent Web Page to be displayed.

In Addition to viewing, Data can be sent to [AirData App Objects](airdata/airdata-app-objects) or external systems through [Data Flows](../studio/data-flows).

Data might need to be transformed, actually as it was in the example above. In order to create the Text for the Text Label with the name, the Expression editor for the greeting text contained:

```javascript
"Good Morning, {{first_name}}"
```

This is an example of using an escape sequence in the string for the Label to Insert some AirData. There are more examples in [Working With Text in Airscript](../airscript/working-with-text).

More complicated transformations of data are better done in [Data Flows](../studio/data-flows) in [Connection Builder](../studio/builder-bar/connection-builder) using the [Transform Data Operation](../data-operations/the-transform-data-operation). This operation can be used for many different things, check out the documentation for more information.
