> For the complete documentation index, see [llms.txt](https://docs.thewalletcrew.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.thewalletcrew.io/developers-guides/scripting/extensions/actito.md).

# Actito scripts

Reference of the Actito profile mapper script, extensions.actito.profile.mapper: registration, the MapFromActitoProfiles handler and an example.

The Actito connector copies `firstName` and `lastName` from an Actito profile onto the wallet account. The profile mapper script adds the other Actito attributes a pass needs, such as a segmentation tier or a preferred store. This page is the reference for `extensions.actito.profile.mapper`. The connector itself is described on the [Actito connector page](https://docs.thewalletcrew.io/connectors/marketing-automation/actito.md); the rules shared by every connector script are in [Connector scripts](https://docs.thewalletcrew.io/developers-guides/scripting/extensions.md).

<details>

<summary><strong>Real-world examples</strong></summary>

* A retailer shows the loyalty tier stored in an Actito profile column on the pass.
* A brand copies the preferred store of the Actito profile onto the account, so that the pass shows the store data.

</details>

## Registration

| Key                                | Slot file                  | Methods (required in **bold**) |
| ---------------------------------- | -------------------------- | ------------------------------ |
| `extensions.actito.profile.mapper` | `actito.profile.mapper.js` | **`MapFromActitoProfiles`**    |

The file sits in `server/scripts/`. The slot is the **Profile mapper** script of the **Advanced** tab of the Actito connector settings, read and written with `GET` and `PUT /api/{tenantId}/admin/extensions/actito/scripts`. When no script is registered, the default mapping applies: `firstName` and `lastName` only.

```js
export default function (context) {
  context.register('extensions.actito.profile.mapper', {
    MapFromActitoProfiles: (data, account) => {}
  });
}
```

## When it runs

The connector calls the mapper each time its customer provider (`actito.profile`) reads an Actito profile to fill the account, right after it has copied `firstName` and `lastName` when the profile carries them. The provider reads nothing, and the mapper does not run, when the account has no `id.actito.profileId` identifier. The mapper has one direction only, from Actito to the account. Writing to Actito is not done by this script.

## Handlers

| Method                  | Parameters        | Returns | Required | Sync or async |
| ----------------------- | ----------------- | ------- | -------- | ------------- |
| `MapFromActitoProfiles` | `data`, `account` | nothing | Required | Synchronous   |

* `data` holds every attribute of the Actito profile, each value as a string. The keys are the column names of the Actito profile table named in **Profile table name** in the connector configuration.
* `account` is the wallet account, a flat dictionary (see [Data objects](https://docs.thewalletcrew.io/developers-guides/scripting/data-objects.md)). The script writes the keys it wants to publish and changes nothing else.

The method returns nothing: it changes `account` in place.

## Errors and edge cases

* **No script registered**: the default mapping applies and nothing is logged as an error.
* **The method is missing** from the registered object: the call fails with `method MapFromActitoProfiles missing` when the connector reaches it.
* **An attribute is absent** from the profile: `data['column']` reads as `undefined`. Test it before copying it.
* **The script throws**: the error fails the read of the Actito profile, and with it the customer provider entry that called it.
* **The handler is declared `async`**: it is not awaited, so changes made after an `await` are lost.

## Example

The script keeps the default mapping and adds a tier and a preferred store. Both are copied only when the profile carries them, so that a missing column never erases a value another provider wrote.

```js
function mapFromActito(data, account) {
  if (data['firstName']) {
    account['firstName'] = data['firstName'];
  }
  if (data['lastName']) {
    account['lastName'] = data['lastName'];
  }
  if (data['loyaltyTier']) {
    account['actito.tier'] = data['loyaltyTier'];
  }
  if (data['preferredStore']) {
    account['storeId'] = data['preferredStore'];
  }
}

export default function (context) {
  context.register('extensions.actito.profile.mapper', {
    MapFromActitoProfiles: mapFromActito
  });
}
```

The column names `loyaltyTier` and `preferredStore` are placeholders: use the names of the brand's own Actito table.

## Common pitfalls

* The registration lines of the starter script are still commented out, so the default mapping applies.
* The column name is typed with another case than in Actito: the attribute reads as `undefined`.
* The mapper expects a number or a boolean: every value of `data` is a string.

## FAQ

<details>

<summary><strong>Can the mapper write back to Actito?</strong></summary>

No. It runs when the profile is read. The wallet installation status is written to Actito by the connector itself, without a script.

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.thewalletcrew.io/developers-guides/scripting/extensions/actito.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
