# Customer Profiles

EARLY ACCESS

___

Connect Chatbots to the Infobip customer data platform, [Customer Profiles](https://www.infobip.com/docs/customer-profiles), to retrieve and update information about end users. In Customer Profiles, this information is stored in Person profiles.

You can do the following:

- When end users interact with the chatbot, capture relevant information from the conversations and store it in Person profiles.
- Retrieve information about end users from their Person profiles.

Customer Profiles is enabled by default when you enable Chatbots.

___

## Attributes

Use attributes to add or retrieve information about end users from Customer Profiles. Use this information to personalize your responses to end users.

The attribute types are as follows:

- [Standard](https://www.infobip.com/docs/customer-profiles/manage-data#standard-attributes): Information in standard fields. Example: Contact information
- [Custom](https://www.infobip.com/docs/customer-profiles/manage-data#custom-attributes): Customized information that is not available as a standard field. Example: End date for a subscription
- [Computed](https://www.infobip.com/docs/customer-profiles/manage-data#computed-attributes): Information obtained through custom formulae, profile scoring, and event aggregation. Use these attributes to do the following:
    - Customize your messages to end users. Example: If the end user purchased a product in the last 7 days, ask them "*Are you contacting us regarding your recent order?*"
    - Prioritize end user requests based on their profile score

You can only retrieve computed attributes from Customer Profiles and cannot update them.

### Attribute mapping

Use custom mapping to map an attribute in Chatbots with an attribute in Customer Profiles. Example: In Chatbots, store the end user's location in the *Location_City* attribute and map it to the *City* attribute in Customer Profiles.

Ensure the attribute type in Chatbots is compatible with that in Customer Profiles. Example: If the attribute type in Chatbots is Boolean, you cannot map it with a Text attribute in Customer Profiles.

When you use the **Get information** action (Customer Profiles to Chatbots), you can map attributes as follows:

| Attribute type in Customer Profiles | Attribute type in Chatbots |
| --- | --- |
| TextGender | Text |
| Decimal numberWhole number | Number |
| True/False | Boolean |
| DateDate Time | Date |
| List of objects | List |

When you use the **Create or update person profile** action (Chatbots to Customer Profiles), you can map attributes as follows:

| Attribute type in Chatbots | Attribute type in Customer Profiles |
| --- | --- |
| TextPhone numberLocationURLEmail | Text |
| NERMO | Text |
| Boolean | True/False |
| List | List of objects |

___

## Custom events

When an end user interacts with the chatbot and performs an action, you can pass this event to Customer Profiles. The event is saved as a [custom event](https://www.infobip.com/docs/customer-profiles/events#custom-events) in Customer Profiles. You can then use this information when the end user interacts with the chatbot again or in other Infobip solutions.

Example: An end user purchases a product during a session with the chatbot. Save this event as a custom event in Customer Profiles. You can then do the following:

- Use the event as context in Chatbots and Inbox: The end user contacts your business again after 3 days. The chatbot or agent can mention the purchase in the initial message. "*How can I help? Are you contacting us regarding your recent purchase?*"
- Follow up with the end user through a Flow campaign in Automation Studio: "*Based on your recent purchase, here are some products that you may like.*"
- Use the event properties to populate [computed attributes](https://www.infobip.com/docs/customer-profiles/manage-data#computed-attributes) in Customer Profiles for use cases such as total lifetime spend, average spend, and most common request. You can then use these attributes to personalize communication in Chatbots or improve segmentation in Automation Studio.
- Mark the Person profile as high priority so that the end user is prioritized the next time they contact your business.

### Process

The process is as follows:

1. In Chatbots, an end user performs an action, such as saving a product to the cart.
2. Save each relevant property of this event in Chatbots attributes. Example: successful addition of a product to cart, and the identifier, name, and price of the product.
3. Pass these attributes to Customer Profiles, where you can save them in a [custom event](https://www.infobip.com/docs/customer-profiles/events#custom-events) in the end user's Person profile.

#### Create a custom event in Customer Profiles

1. Log on to the Infobip [web interface](https://portal.infobip.com//).
2. Go to **Customer Profiles** > **Events** > **Custom Events**.
3. Select **Create event**.
4. Add the **Event Name** and **Description**. Example: To save the event of an end user adding a product to cart, create the event *AddedToCart*.
5. Select **Add event property**.
6. Enter the event **Property Name**. Create as many properties as required. Example: To save the event of adding a product to cart, create properties for successful addition of the product to cart (*addedCart*), identifier of the product (*productID*), name of the product (*productName*), and price of the product (*productPrice*).
7. Select **Save**.

#### Send a custom event to Customer Profiles

1. Go to **Automation Studio** > **Chatbots** and open your chatbot.
2. In the **Attributes** tab, do the following:
    1. Create the attributes in which you want to save the event properties. Example: To save the event of adding a product to cart, create attributes for successful addition of the product to cart (*addedCart*), identifier of the product (*productID*), name of the product (*productName*), and price of the product (*productPrice*).
       For each attribute, ensure you create equivalent event properties in Customer Profiles. Also, ensure the attribute type is [compatible](#attribute-mapping) with the event property you created for the event in Customer Profiles.
    2. (Optional) Create an attribute to identify the Person profile. Example: *customerContact*.
3. Create a dialog to send the event from Chatbots to Customer Profiles. Example: *Added to Cart*.
4. Drag the **Customer Profiles custom event** element.
5. Configure the element as described in the [Customer Profiles custom event](https://www.infobip.com/docs/automation-studio/chatbots/chatbot-elements/core-elements#customer-profiles-custom-event) documentation.
6. In the **Customer Profiles custom event** element, find the Person profile in which you want to save the event. Do the following:
    1. In the **Contact information attribute** field, enter the Chatbots attribute that contains customer contact information. Example: *customerContact*.
    2. In the **Contact information attribute type** field, select the attribute type. Ensure this field matches the data type of the attribute you selected in the **Contact information attribute** field.
7. In the **Custom event configuration** section, specify the event to save against the Person profile. To do so, use the attribute in which the event is saved.
    1. Select **Add custom event**.
    2. Choose the event you created in Customer Profiles. Example: *AddedToCart*.
8. (Optional) Add properties to the event.
    1. Select **Add attribute mappings**.
    2. Choose one or more Chatbots attributes that contain the event properties. Example: *addedCart*, *productID*, *productName*, and *productPrice*.
    3. For each Chatbots attribute, choose an equivalent event property you created for the event in Customer Profiles. Example: *addedCart*, *productID*, *productName*, and *productPrice*. Ensure the Chatbots attribute type and Customer Profiles event property are [compatible](#attribute-mapping).

       Chatbots does not support **dateTime** property. To pass a dateTime value into an event, save the value in a Text attribute in Chatbots and map the attribute to a Text property type.
9. Select **Add**.
10. (Optional) Check whether the event was saved successfully to the Person profile. Add a [**Conditions**](https://www.infobip.com/docs/automation-studio/chatbots/chatbot-elements/core-elements#conditions) element. Configure the element as follows:
    1. In the attribute field, choose the predefined attribute **lastCustomerProfilesStatusCode**.
    2. Set the operator to **is**.
    3. Specify the status — **Success**.
    4. Branch the chatbot flow as required.

The event, along with its properties, is saved in the end user's Person profile in Customer Profiles.

___

## Product events

Save Chatbots [product events](https://www.infobip.com/docs/customer-profiles/events#product-events-standard-events) such as the start or end of a chatbot session to [Person profiles](https://www.infobip.com/docs/customer-profiles/get-started#person-profile) in Customer Profiles. When an end user starts a session with the chatbot, the following happens:

- If a profile exists for the end user, the events are added to the profile.
- If a profile does not exist, a new profile of type Customer is automatically created in Customer Profiles, and the product events are added to this profile.

NOTE
To use this functionality, [enable the relevant product events](https://www.infobip.com/docs/customer-profiles/events#enable-disable-standard-events) for Chatbots in Customer Profiles.

___

## Tags

Use the [**Customer Profiles tags**](https://www.infobip.com/docs/automation-studio/chatbots/chatbot-elements/core-elements#customer-profiles-tags) element in Chatbots to update tags in Customer Profiles. You can do the following:

- **Add or create tags**: Add one or more existing tags to a profile or create new tags.
- **Get tags**: Verify whether the specified tags are present in a profile.
- **Remove tags**: Remove one or more tags from a profile.

___

## Create a Customer Profiles chatbot

This section shows how to build a basic chatbot that connects with Customer Profiles. Follow these steps:

1. In the chatbot editor, drag and drop the [Customer Profiles profile](https://www.infobip.com/docs/automation-studio/chatbots/chatbot-elements/core-elements#customer-profiles-profile) element into a dialog.
2. Select the **Customer Profiles profile** element you added.
3. In the **Select action** field, specify the required action. Choose **Create or update person profile** to get information from Customer Profiles or post information to Customer Profiles.
4. In the **Contact information attribute** field, specify the attribute to use. You can use a standard channel-specific attribute stored in Customer Profiles, or a custom attribute in Chatbots. By default, this value is set to **endUserDestination**.
5. For custom attributes, select **Add attribute mapping** to map the attributes in Customer Profiles and Chatbots. See the guidelines in the [Attributes](#attributes) > Attribute mapping section.
6. Check whether the event was saved successfully to the Person profile. Add a **Conditions** element. Configure the element as follows:
    - In the attribute field, choose the predefined attribute **lastCustomerProfilesStatusCode**.
    - Set the operator to **is**.
    - Specify the status — **Success**.
    - Branch the chatbot flow as required.

If you use List attributes, the list values are added to the list. To overwrite list values instead of adding them, use the overwrite option when you map attributes. You can overwrite the list only when creating or updating profiles.

___