# Customer Segment

**Action ID:** `customer_segment`

## Description

Generate customer segment from Amazon Personalize.

## Input Parameters

| Name       | Type   | Required | Default                      | Description                              |
| ---------- | ------ | :------: | ---------------------------- | ---------------------------------------- |
| prompt     | string |     ✓    | -                            | The prompt to use for segment generation |
| car\_model | string |     -    | COROLLA CROSS PREMIUM - 2022 | The car model for segmentation           |

<details>

<summary>View JSON Schema</summary>

```json
{
  "description": "Customer segment node input.",
  "properties": {
    "prompt": {
      "description": "The prompt to use for the question answering.",
      "title": "Prompt",
      "type": "string"
    },
    "car_model": {
      "default": "COROLLA CROSS PREMIUM - 2022",
      "description": "The car model to use for the question answering.",
      "enum": [
        "YARIS CROSS HYBRID - 2021",
        "COROLLA CROSS PREMIUM - 2022",
        "RAV4 HYBRID - 2022",
        "HARRIER HYBRID PREMIUM - 2022",
        "COROLLA ALTIS STANDARD - 2023",
        "COROLLA ALTIS ELEGANCE - 2023",
        "CAMRY HYBRID STANDARD - 2024",
        "CAMRY HYBRID ELEGANCE - 2024",
        "SIENTA HYBRID ELEGANCE - 2021"
      ],
      "title": "Car model",
      "type": "string"
    }
  },
  "required": [
    "prompt"
  ],
  "title": "CustomerSegmentInput",
  "type": "object"
}
```

</details>

## Output Parameters

| Name | Type  | Description                    |
| ---- | ----- | ------------------------------ |
| data | array | Array of customer segment data |

<details>

<summary>View JSON Schema</summary>

```json
{
  "description": "Customer segment node output.",
  "properties": {
    "data": {
      "items": {},
      "title": "Data",
      "type": "array"
    }
  },
  "required": [
    "data"
  ],
  "title": "CustomerSegmentNodeOutput",
  "type": "object"
}
```

</details>

## How It Works

This node uses Amazon Personalize to generate customer segments based on a natural language prompt and optionally a car model. The system analyzes customer behavior patterns, preferences, and demographics to identify groups of customers who match the specified criteria. The prompt guides the segmentation logic, and the car model filters results to customers interested in specific vehicle types.

## Usage Examples

### Example 1: Find High-Value Customers

**Input:**

```
prompt: "Find customers who have made multiple purchases in the last 6 months"
car_model: "CAMRY HYBRID ELEGANCE - 2024"
```

**Output:**

```
data: [
  {"customer_id": "C12345", "purchase_count": 3, "total_value": 85000},
  {"customer_id": "C67890", "purchase_count": 2, "total_value": 120000}
]
```

### Example 2: Target First-Time Buyers

**Input:**

```
prompt: "Identify potential first-time car buyers"
car_model: "YARIS CROSS HYBRID - 2021"
```

**Output:**

```
data: [
  {"customer_id": "N00123", "age_group": "25-30", "interest_score": 0.85},
  {"customer_id": "N00456", "age_group": "22-28", "interest_score": 0.78}
]
```

### Example 3: Segment by Engagement

**Input:**

```
prompt: "Find customers who engaged with our emails but haven't purchased"
car_model: "COROLLA CROSS PREMIUM - 2022"
```

**Output:**

```
data: [
  {"customer_id": "E99001", "email_opens": 15, "last_engagement": "2024-11-20"},
  {"customer_id": "E99002", "email_opens": 8, "last_engagement": "2024-11-22"}
]
```

## Common Use Cases

* **Targeted Marketing**: Identify customer segments for personalized marketing campaigns
* **Product Recommendations**: Find customers likely to be interested in specific car models
* **Churn Prevention**: Identify at-risk customers who may need re-engagement
* **Upsell Opportunities**: Find customers ready for premium model upgrades
* **Campaign Optimization**: Segment audiences for A/B testing and campaign targeting
* **Customer Insights**: Analyze customer behavior patterns across different demographics
* **Lead Scoring**: Prioritize leads based on likelihood to purchase specific models

## Error Handling

| Error Type        | Cause                                       | Solution                                                    |
| ----------------- | ------------------------------------------- | ----------------------------------------------------------- |
| Invalid Prompt    | Prompt is too vague or malformed            | Provide specific, clear segmentation criteria in the prompt |
| No Segments Found | No customers match the criteria             | Broaden your search criteria or try different car models    |
| Model Not Found   | Car model value doesn't match enum options  | Use one of the predefined car model options from the list   |
| Personalize Error | Amazon Personalize service error            | Check AWS Personalize status and configuration              |
| Empty Data        | No customer data available for segmentation | Ensure customer data has been imported into Personalize     |
| Timeout Error     | Query took too long to process              | Simplify the prompt or reduce the scope of segmentation     |

## Notes

* **Car Models**: The node supports specific Toyota car models. Select the model most relevant to your campaign.
* **Prompt Engineering**: Clear, specific prompts yield better segmentation results. Include timeframes, behaviors, or demographics.
* **Amazon Personalize**: This node requires a configured Amazon Personalize campaign with customer data.
* **Data Privacy**: Ensure customer data handling complies with privacy regulations (GDPR, CCPA, etc.).
* **Segment Size**: Very specific prompts may return small segments. Balance specificity with reach.
* **Real-Time Updates**: Segments reflect the current state of data in Amazon Personalize.
* **Cost Considerations**: Amazon Personalize charges based on data processing and recommendations generated.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.agenticflow.ai/reference/nodes/customer_segment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
