> ## Documentation Index
> Fetch the complete documentation index at: https://client-integrations-api-dev.sequen.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat API

> Interactive chat bot style conversation for item discovery.

# Chat API

Interactive chat bot style conversation for item discovery. Pass in `conversation_id` to continue an existing conversation.

## Endpoint

```
POST /chat
```

## Request Body (`ChatRequest`)

| Field             | Type    | Required | Description                                                                                   |
| :---------------- | :------ | :------- | :-------------------------------------------------------------------------------------------- |
| `message`         | String  | Yes      | The chat message. Example: 'I am looking for a birthday gift for my dad'.                     |
| `conversation_id` | String  | No       | A string uniquely identifying a conversation. Pass this to continue an existing conversation. |
| `session_id`      | String  | No       | A string uniquely identifying a session.                                                      |
| `user_id`         | String  | No       | A string uniquely identifying a user.                                                         |
| `events`          | Array   | No       | A list of events associated with the conversation. See Event object structure.                |
| `limit`           | Integer | No       | The maximum number of items to return. Default is 4.                                          |

### Event Object Structure

The `events` array contains a list of Event objects, each describing a user interaction or context relevant to the conversation.

| Field         | Type   | Required | Description                                                  |
| :------------ | :----- | :------- | :----------------------------------------------------------- |
| `timestamp`   | String | Yes      | ISO 8601 timestamp of the event.                             |
| `type`        | String | Yes      | Type of the event (e.g., `browse`, `click`, `purchase`).     |
| `item_id`     | String | No       | The ID of the item associated with the event, if applicable. |
| `description` | String | No       | A free-text description of the event.                        |

## Example Request

<CodeBlock title="POST /chat Request Example (ChatRequest)">
  ```json Example Body theme={null}
  {
    "message": "Which desk would you recommend for heavy tools?",
    "conversation_id": "c8a7d9f6-e4b1-42d3-8c2e-5a8d4f31b96f",
    "session_id": "2f396d29-fb98-44cf-996c-e8c66fc02fbe",
    "user_id": "u8a7d9f6",
    "events": [
      {
        "timestamp": "2024-06-14T10:00:00Z",
        "type": "browse",
        "item_id": "ST678VG",
        "description": "Viewed workshop desk details page"
      },
      {
        "timestamp": "2024-06-14T10:03:00Z",
        "type": "click",
        "item_id": "ST678VG",
        "description": "Clicked on product image"
      }
    ]
  }
  ```
</CodeBlock>

## Response Body (`ChatResponse`)

| Field             | Type   | Description                                                  |
| :---------------- | :----- | :----------------------------------------------------------- |
| `conversation_id` | String | A string uniquely identifying the conversation.              |
| `message`         | String | The chat message response.                                   |
| `items`           | Array  | A list of items (Item objects) related to the chat response. |

## Example Response

<CodeBlock title="POST /chat Response Example (ChatResponse)">
  ```json Example Response theme={null}
  {
    "conversation_id": "9b022f99-358e-4041-904d-abb9bd15731a",
    "message": "Here are some great gift ideas for your dad.",
    "items": [
      {
        "item_id": "ST678VG",
        "title": "Itelio workshop desk",
        "status": "active",
        "description": "Solid wood workshop desk for the discerning customer.",
        "price": "999.99"
      }
    ]
  }
  ```
</CodeBlock>

## Responses

* **`200 OK`**: Successful Response (`ChatResponse`)
* **`422 Validation Error`**: (`HTTPValidationError`)
