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

# Chat Management

> Methods for managing and interacting with chats through communication channels

## Overview

The Chat Management module provides functionality to retrieve, view, archive, and manage chats within your communication channels. These methods allow you to efficiently organize conversations and access chat history.

## Available Methods

### All Chat

Retrieve a list of all chats with pagination support.

<Tabs>
  <Tab title="Basic Usage">
    ```php theme={null}
    use CrunchzApp\CrunchzApp;

    CrunchzApp::channel()
      ->allChat(
        limit: 12,
        offset: 1,
      );
    ```
  </Tab>

  <Tab title="Parameters">
    | Parameter | Type    | Required | Description                                          |
    | --------- | ------- | -------- | ---------------------------------------------------- |
    | limit     | integer | No       | Maximum number of chats to retrieve (default: 10)    |
    | offset    | integer | No       | Number of chats to skip (for pagination, default: 0) |
  </Tab>
</Tabs>

<Note>
  The `allChat` method returns chats sorted by most recent activity by default.
</Note>

### Chat Details

Retrieve detailed information about a specific chat with a contact.

<Tabs>
  <Tab title="Basic Usage">
    ```php theme={null}
    use CrunchzApp\CrunchzApp;

    CrunchzApp::channel()
      ->contact('xxx@c.us')
      ->chatDetail();
    ```
  </Tab>

  <Tab title="Parameters">
    | Parameter | Type   | Required | Description                                                |
    | --------- | ------ | -------- | ---------------------------------------------------------- |
    | contact   | string | Yes      | The contact ID in the format '[xxx@c.us](mailto:xxx@c.us)' |
  </Tab>
</Tabs>

### Archive Chat

Archive a chat to organize your chat list and hide less active conversations.

```php theme={null}
use CrunchzApp\CrunchzApp;

CrunchzApp::channel()
  ->contact('xxx@c.us')
  ->archiveChat();
```

<Warning>
  Archiving a chat doesn't delete any messages. It simply moves the chat to the archived section.
</Warning>

### Unarchive Chat

Restore a previously archived chat to your active chat list.

```php theme={null}
use CrunchzApp\CrunchzApp;

CrunchzApp::channel()
  ->contact('xxx@c.us')
  ->unArchiveChat();
```

## Common Use Cases

<AccordionGroup>
  <Accordion title="Managing Active Conversations">
    Use the archive and unarchive features to keep your active chat list clean and focused on current conversations.
  </Accordion>

  <Accordion title="Implementing Chat History">
    Use the chat details method to display complete conversation history with a specific contact.
  </Accordion>

  <Accordion title="Building a Chat Interface">
    Combine these methods to create a full-featured chat interface with pagination, archiving, and detailed views.
  </Accordion>
</AccordionGroup>
