> ## Documentation Index
> Fetch the complete documentation index at: https://mako-docs.devinagiffy.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Send Chat Message

> Send a message to Hitler AI and receive a conversational response

<Note>
  This endpoint requires authentication via JWT (for web users) or API key (for bot services).
</Note>

## Overview

The chat endpoint provides conversational AI capabilities powered by Anthropic tool use. The LLM understands natural language in any supported language, decides which tools to call (get\_tasks, create\_task\_draft, log\_mood, etc.), and returns responses grounded in real data. When tasks are detected, it creates drafts for user confirmation.

## Request

<ParamField body="message" type="string" required>
  The user's message (1-2000 characters)
</ParamField>

<ParamField body="platform" type="string" required>
  Source platform: `web`, `slack`, `teams`, or `whatsapp`
</ParamField>

<ParamField body="platformUserId" type="string" required>
  User identifier on the platform (user ID or UUID)
</ParamField>

<ParamField body="history" type="array">
  Recent conversation history for context. Each item should have `role` (`"user"` or `"assistant"`)
  and `content` (the message content).
</ParamField>

## Response

<ResponseField name="text" type="string">
  The AI's response message
</ResponseField>

<ResponseField name="intent" type="string">
  Detected intent: `task_create`, `task_list`, `mood`, `help`, `greeting`, or `general`
</ResponseField>

<ResponseField name="taskDraft" type="object">
  Single task draft (when one task is detected). Contains `id` (Draft UUID), `title` (Parsed task
  title), `priority` (1-5), and optional `dueDate`.
</ResponseField>

<ResponseField name="taskDrafts" type="array">
  Multiple task drafts (when several tasks are detected)

  Each item contains `id`, `title`, `priority`, and optional `dueDate`
</ResponseField>

<ResponseField name="tasks" type="array">
  Task list returned when the LLM calls `get_tasks` tool. Each item contains `id`, `title`,
  `status`, `priority`, `dueDate`, `createdAt`
</ResponseField>

<ResponseField name="completedTask" type="object">
  Task that was just completed via the `complete_task` tool. Contains `id`, `title`, `status`
</ResponseField>

<ResponseField name="moodLogged" type="object">
  Mood entry just logged via the `log_mood` tool. Contains `id`, `value`, `note`, `createdAt`
</ResponseField>

<ResponseField name="moodHistory" type="array">
  Recent mood entries returned from `get_mood_history` tool
</ResponseField>

<ResponseField name="taskStats" type="object">
  Task statistics from `get_task_stats` tool. Contains `totalTasks`, `completedTasks`,
  `completionRate`, `openTasks`, `overdueTasks`
</ResponseField>

<ResponseField name="showMoodPrompt" type="boolean">
  Whether to show mood logging UI
</ResponseField>

<ResponseField name="inferredMood" type="integer">
  Mood value (1-5) inferred from the message, if detected
</ResponseField>

## Intents

| Intent        | Description                 | Typical Response                    |
| ------------- | --------------------------- | ----------------------------------- |
| `task_create` | User wants to create a task | Returns `taskDraft` or `taskDrafts` |
| `task_list`   | User asks about their tasks | Returns task summary in `text`      |
| `mood`        | User wants to log mood      | Sets `showMoodPrompt: true`         |
| `help`        | User asks for help          | Returns help information            |
| `greeting`    | Casual greeting             | Friendly response                   |
| `general`     | General conversation        | Conversational response             |

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.hitler.app/api/chat" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "message": "tomorrow I need to review the budget and send invoices",
      "platform": "web",
      "platformUserId": "user-123",
      "history": []
    }'
  ```

  ```typescript TypeScript theme={null}
  const response = await api.chat({
    message: "tomorrow I need to review the budget and send invoices",
    platform: "web",
    platformUserId: "user-123",
    history: [],
  });

  // Handle multiple task drafts
  if (response.taskDrafts?.length > 0) {
    console.log(`Created ${response.taskDrafts.length} drafts`);
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Multiple Tasks theme={null}
  {
    "text": "got it, adding 2 tasks",
    "intent": "task_create",
    "taskDrafts": [
      {
        "id": "draft-uuid-1",
        "title": "review the budget",
        "priority": 3,
        "dueDate": "2024-01-16T09:00:00.000Z"
      },
      {
        "id": "draft-uuid-2",
        "title": "send invoices",
        "priority": 3,
        "dueDate": "2024-01-16T09:00:00.000Z"
      }
    ],
    "showMoodPrompt": false,
    "inferredMood": null
  }
  ```

  ```json 200 - Single Task theme={null}
  {
    "text": "got it, adding \"finish the report\"",
    "intent": "task_create",
    "taskDraft": {
      "id": "draft-uuid-123",
      "title": "finish the report",
      "priority": 2,
      "dueDate": "2024-01-15T17:00:00.000Z"
    },
    "showMoodPrompt": false,
    "inferredMood": null
  }
  ```

  ```json 200 - Greeting theme={null}
  {
    "text": "hey! doing good, what's up?",
    "intent": "greeting",
    "showMoodPrompt": false,
    "inferredMood": null
  }
  ```

  ```json 200 - Mood Detected theme={null}
  {
    "text": "sounds like you're having a rough day. hang in there!",
    "intent": "general",
    "showMoodPrompt": false,
    "inferredMood": 2
  }
  ```
</ResponseExample>

## Service Endpoint

For bot services (Slack, Teams), use the service endpoint with API key authentication:

```
POST /api/chat/service
```

This endpoint uses the `X-API-Key` header instead of JWT Bearer token.

<RequestExample>
  ```bash cURL (Service) theme={null}
  curl -X POST "https://api.hitler.app/api/chat/service" \
    -H "X-API-Key: hitler_org123_secret456" \
    -H "Content-Type: application/json" \
    -d '{
      "message": "what tasks do I have?",
      "platform": "slack",
      "platformUserId": "U123ABC456"
    }'
  ```
</RequestExample>

## Language Support

Hitler supports 13 languages with automatic detection:

| Language   | Code         | Script Detection        |
| ---------- | ------------ | ----------------------- |
| English    | `english`    | Latin (default)         |
| Hinglish   | `hinglish`   | Hindi patterns          |
| Spanish    | `spanish`    | Spanish diacritics      |
| French     | `french`     | French diacritics       |
| German     | `german`     | German characters       |
| Portuguese | `portuguese` | Portuguese diacritics   |
| Italian    | `italian`    | Italian patterns        |
| Dutch      | `dutch`      | Dutch words             |
| Japanese   | `japanese`   | Hiragana/Katakana/Kanji |
| Korean     | `korean`     | Hangul                  |
| Chinese    | `chinese`    | CJK ideographs          |
| Arabic     | `arabic`     | Arabic script           |
| Russian    | `russian`    | Cyrillic                |

The AI automatically detects the user's language and responds appropriately:

```json Request (Spanish) theme={null}
{
  "message": "añade una tarea: revisar el presupuesto",
  "platform": "web",
  "platformUserId": "user-123"
}
```

```json Response (Spanish) theme={null}
{
  "text": "vale, añadiendo \"revisar el presupuesto\"",
  "intent": "task_create",
  "taskDraft": {
    "id": "draft-uuid",
    "title": "revisar el presupuesto",
    "priority": 3
  }
}
```

### Language Endpoints

**Get Supported Languages**

```
GET /api/chat/languages
```

Returns the list of all supported languages.

**Get User's Language**

```
GET /api/chat/language
Authorization: Bearer YOUR_TOKEN
```

Returns the user's current language preference.

**Update User's Language**

```
PATCH /api/chat/language
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

{ "language": "spanish" }
```

Sets the user's preferred language, overriding auto-detection.

## Notes

* Task drafts created via chat must be confirmed using the [Confirm Draft](/api-reference/tasks/confirm-draft) endpoint
* The AI uses conversation history for context, but history is not persisted server-side
* Mood inference happens silently and doesn't interrupt the conversation
* Response messages are kept short (8-12 words) for chat-like UX
* Language is auto-detected from each message but can be manually set
