# Fetch achievement data from Talon.One using Adobe

> In this tutorial, let's set up Adobe Experience Platform to fetch achievement data from Talon.One using the Talon.One Batch Source Connector.

> For the complete documentation index, see [llms.txt](https://docs.talon.one/llms.txt).

After that, you can use [Adobe Journey
Optimizer](https://business.adobe.com/products/journey-optimizer.html),
for example, to send a reward code to every customer who completed a specific achievement
in the last week.

## How it works

If a customer has completed an
[achievement](/docs/product/achievements/overview.md) in a session,
this is recorded as an
[effect](/docs/dev/integration-api/api-effects.md#increaseachievementprogress) in a
`talon_session_closed` [event](/docs/dev/concepts/entities/events.md#built-in-events) in Talon.One.

The batch source connector pulls these events from Talon.One, filtered by event type.
Adobe Journey Optimizer can then act on that data to send targeted messages.

This approach is well suited for handling high-volume batched event data. For use cases
where you need to react immediately as events occur, use the [streaming events
source](/docs/dev/technology-partners/adobe/stream-loyalty-tier-updates-adobe.md).

For more information, see our [overview page](/docs/dev/technology-partners/adobe.md) and the
[documentation provided by
Adobe](https://experienceleague.adobe.com/en/docs/experience-platform/sources/ui-tutorials/create/loyalty/talon-one-batch).

## Talon.One requirements

- You have an [Application](/docs/product/applications/create-and-manage-applications.md) and [campaign](/docs/product/campaigns/create-and-manage-campaigns.md)
  in Talon.One.
- The **Achievements** feature
  is [enabled](/docs/product/campaigns/settings/manage-campaign-features.md) in your campaign.

## Set up the integration

<StepsContainer>

### Create an API key in Talon.One

In the Campaign Manager, create a [Management API key](/docs/product/account/dev-tools/manage-mapi-keys.md#create-a-management-api-key).

We will use the API key in a later step to configure the batch source connector.

### (Optional) Create an achievements schema in Adobe

If you already have a [schema](https://experienceleague.adobe.com/en/docs/experience-platform/xdm/tutorials/create-schema-ui)
in Adobe Experience Platform that includes the necessary fields to capture achievement
data, you can skip this step.

For this tutorial, let's assume we don't have a suitable schema yet. As a starting point, we can use the
**Loyalty Challenge State** field group provided by Adobe.

1. In Adobe Experience Platform, open the **Schemas** workspace.
1. At the top right of the page, click **Create schema**.
1. Choose **Manual** and click **Select**.
1. Choose **Experience Event** as the schema base class and click **Next**.
1. In **Name and review**, provide a name for the schema, for example, `Talon.One
   Achievements Schema`, and click **Finish**. The schema editor opens.
1. In the left sidebar, under **Composition**, next to **Field groups**, click **Add**.
1. In the list of field groups, find **Loyalty Challenge State**, select it, and click
   **Add field groups**.The schema should now include an
   `_experience.ajo.loyalty.challenge` object.
1. In the right sidebar, under **Schema properties**, enable **Profile**, confirm the
   dialog regarding the primary identity, and click **Enable**.
1. Click **Save**.

### Create the achievement in Talon.One

Let's create the achievement and complete it, so that we have some data to work with
when configuring the batch connector:

1. In your campaign, [create an
   achievement](/docs/product/achievements/create-achievements.md) with the
   following properties:
    - **Type**: [Recurring on
      completion](/docs/product/achievements/overview.md#recurring-on-completion-achievements)
    - **Name**: `Stamp Collector`
    - **API name**: `stamp_collector`
    - **Description**:
      `You earned a stamp with every purchase and filled your card. Reward unlocked.`
    - **Target**: `5`
1. [Create a rule](/docs/product/rules/create-and-manage-rules.md) with the following
   properties:

   | What           | Name                                               | Properties                                                                                                      |
   | -------------- | -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
   | **Conditions** | Check for event typesand custom event values | **Event type**: `Customer Session Closing`                                                   |
   | **Effects**    | Update customer progress                           | **Achievement name**: Select the achievement you created.**Update progress by**: `1` |

   Now, whenever a customer session closes, the achievement progress is increased by `1`.
   When the customer reaches the target of `5`, the achievement is marked as completed.
1. Send five API calls to the [Update customer session](/integration-api#tag/Customer-sessions/operation/updateCustomerSessionV2)
   endpoint, each with a different `customerSessionId` and with the `state` property set
   to `closed`.

The last API call should trigger the completion of the achievement for the corresponding
customer session, and create an effect of type [increaseAchievementProgress](/docs/dev/integration-api/api-effects.md#increaseachievementprogress) with the
`isJustCompleted` property set to `true`.

### Configure the batch source connector in Adobe

1. Download the [example achievement mapping file](/files/adobe-achievement-mappings.csv).
1. In Adobe Experience Platform, open the **Sources** workspace.
1. On the **Catalog** page, in the **Loyalty** section, find the **Talon.One Batch Source
   Connector**. If available, use the **(Beta)** version to access the latest features and
   improvements.
1. Click **Set up** or, if you used the connector before, **Add data**.
1. Select **New account** and provide the following authentication details:
   - **Account name**: Type a descriptive name, for example, `Talon.One Batch Account`.
   - **baseUrl**: Type the base URL of your Talon.One deployment, for example,
     `mycompany.europe-west1.talon.one`.
   - **Talon.One Management API key**: Type `ManagementKey-v1 `, followed by the API key
     you created in the previous step. For example, `ManagementKey-v1 abcdef1234567890`.
1. Click **Connect to source**, then click **Next**.
1. In **Select data**, provide the following details:
   
   - **applicationId**: The ID of your Talon.One Application.
       :::tip
       To see the Application ID, open your Talon.One application and check the URL in
       your browser. For example, if the URL is
       `https://mycompany.europe-west1.talon.one/applications/198/`, the application ID is
       `198`.
       :::
   - **sessionType**: The type of the [built-in
     event](/docs/dev/concepts/entities/events.md#built-in-events). In this tutorial, we
     want to track completed achievements in closed sessions, so we use
     `talon_session_closed`.
   
1. Click **Select**, verify that data has been fetched, and click **Next**.
   :::important
   Without data, you will **not** be able to complete the next steps.
   :::
1. In **Dataset details**, create a new dataset based on the schema you
   [created](#optional-create-an-achievements-schema-in-adobe) and name it, for example,
   `Talon.One Achievements Dataset`.
1. Enable the **Profile dataset** option.
1. In **Dataflow details**, provide a name for the dataflow, for example,
   `Talon.One Achievements Dataflow`, and click **Next**.
1. In **Mapping**, click **Clear all**.
1. Click **Import mapping** > **Import mapping from file**, upload the example mapping
   file from step 1, and click **Next**.
1. In **Scheduling**, choose how often you want the dataflow to run. To run it once a
   week, select **Week** and set the interval to `1`.
1. Click **Next** and review the dataflow details. If everything looks good, click
   **Finish**.

The batch source connector now runs immediately and again next week, pulling any new
achievement data from Talon.One into Adobe Experience Platform.

### Preview the data

Let's check if the achievement data has arrived in Adobe Experience Platform:

1. In Adobe Experience Platform, open the **Datasets** workspace and open the dataset you
   [created](#configure-the-batch-source-connector-in-adobe) for this tutorial, for example,
   `Talon.One Achievements Dataset`.
1. In the top right of the page, click **Preview dataset** to check for new data. If
   the button is disabled and labeled **Preview not available**, wait and check again. It
   can take several minutes for the data to be received from Talon.One and
   appear in the dataset.

### Next steps

Now that you have achievement data in Adobe Experience Platform, you can use it to
trigger personalized customer journeys in Adobe Journey Optimizer.

For example, you can set up a journey that sends a congratulatory email with a unique
reward code to customers who completed a specific achievement in the last week.

</StepsContainer>
