# Gladly

[Gladly](https://www.gladly.com/) is a customer service platform that leverages AI to deliver personalized agent-assisted customer service and enhance customer relationships.

Find the open source code for this destination in the [GitHub repository](https://github.com/rudderlabs/rudder-transformer/tree/main/src/cdk/v2/destinations/gladly/).

## Connection compatibility

{{< destination-config >}}

## Setup

1. In your [RudderStack dashboard](https://app.rudderstack.com/), go to **Directory** > **Destinations** > **Cloud Destinations**  and search for **Gladly**.
2. Connect your source and click **Continue**.

### Connection settings

Configure the following settings to set up Gladly as a destination in RudderStack:

- **Name**: Assign a name to uniquely identify the destination.
- **API Token**: Enter your [Gladly API token](#faq) by going to **Settings** > **API Tokens** in your Gladly dashboard.
- **Domain**: Enter your Gladly domain. 
- **User Name**: Enter your Gladly agent email. You can find it in your Gladly dashboard under **Settings** > **Users** > **Email**.

## Identify

You can use the [`identify`]({{< ref "event-spec/standard-events/identify.md" >}}) call to send user details like profile and contact information, notes, and transactions to Gladly.

RudderStack sends this information to Gladly using their [`Customers`](https://developer.gladly.com/rest/#tag/Customers) REST API endpoint.

A sample `identify` call is shown:

```javascript
rudderanalytics.identify("1hKOmRA4GRlm", {
  name: "Alex Keener",
  email: "alex@example.com",
  createdAt: "Mon May 19 2019 18:34:24 GMT+0000 (UTC)",
})
```

### Traits mapping

RudderStack maps the following `identify` traits to the [Gladly attributes](https://developer.gladly.com/rest/#operation/createCustomer):

| RudderStack property | Gladly property | Data type |
| :---- | :----| :-----|
| `userId` <br /> <span style="color: #4D4DFF;font-size:12px;">Required</span>   | `id` | String |
| `traits.name` <br /> `context.traits.name` | `name` | String |
| `traits.email` <br /> `context.traits.email` | `emails[0].original` | String |
| `traits.phone` <br /> `context.traits.phone` | `phones[0].original` | String |
| `traits.image_url` <br /> `context.traits.image_url` | `image` | String |
| `traits.address` <br /> `context.traits.address` | `address` | String |
| `externalId` | `externalCustomerId` | String |

{{< info >}}
RudderStack sends any other user information apart from the above-mentioned traits as `customAttributes`.
{{< /info >}}

Note that RudderStack currently does not support additional email properties. However, you can send this information to Gladly by sending an `emailProperties` object in your event as follows:

```json
{
  "emailProperties": [{
      "<traits.email1>": {
        "normalised": "",
        "primary": true,
        "newKey": ""
      }
    },
    {
      "<traits.email2>": {
        "normalised": "",
        "primary": false,
        "newKey": ""
      }
    }
  ]
}
```

## FAQ

#### **Where can I find the Gladly API token?**

1. Log in to your Gladly dashboard.

{{< warning >}}
Each organization has its own unique Gladly login URL. Make sure to log in using the correct URL. Contact your Gladly customer success team for more information.
{{< /warning >}}


2. Go to **Settings**. Under **APP DEVELOPER TOOLS**, click **API Tokens**.

{{< image src="images/event-stream-destinations/gladly-api-token.webp" alt="Gladly API token" >}}


