> ## 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.

# Send Message

> Comprehensive guide to sending various types of messages and managing message interactions via WhatsApp

## Overview

The Send Message module provides a complete set of methods for sending different types of content, managing message interactions, and controlling chat status indicators through WhatsApp. These methods allow you to create rich, interactive messaging experiences for your users.

## Content Types

Send various types of content to engage your audience with multimedia and interactive elements.

### Text Messages

Send simple text messages to your contacts.

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

    CrunchzApp::channel()
        ->contact('xxx@c.us')
        ->text(
            message: 'This is a message from you'
        )
        ->send();
    ```
  </Tab>

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

<Note>
  Text messages support markdown formatting for **bold**, *italic*, ~~strikethrough~~, and `code blocks`.
</Note>

### Image Messages

Share images with optional captions.

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

    CrunchzApp::channel()
        ->contact('xxx@c.us')
        ->image(
            caption: 'Check out this image!',
            mimeType: 'image/png',
            filename: 'image.png',
            url:'https://raw.githubusercontent.com/CrunchzApp/asset-example/main/examples/logo.png'
        )
        ->send();
    ```
  </Tab>

  <Tab title="Parameters">
    | Parameter | Type   | Required | Description                                         |
    | --------- | ------ | -------- | --------------------------------------------------- |
    | url       | string | Yes      | The URL of the image to send                        |
    | caption   | string | No       | Optional text caption for the image                 |
    | mimeType  | string | No       | The MIME type of the image (default: auto-detected) |
    | filename  | string | No       | Custom filename for the image                       |
  </Tab>
</Tabs>

<Warning>
  Supported image formats include JPG, PNG, and WebP. Maximum file size is 16MB.
</Warning>

### Location Messages

Share geographic locations with your contacts.

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

    CrunchzApp::channel()
        ->contact('xxx@c.us')
        ->location(
            latitude: '-6.142157673038987',
            longitude: '106.19428522218833',
            title: 'CrunchzApp HQ'
        )
        ->send();
    ```
  </Tab>

  <Tab title="Parameters">
    | Parameter | Type   | Required | Description                         |
    | --------- | ------ | -------- | ----------------------------------- |
    | latitude  | string | Yes      | Latitude coordinate                 |
    | longitude | string | Yes      | Longitude coordinate                |
    | title     | string | No       | Name or description of the location |
  </Tab>
</Tabs>

### Voice Messages

Send voice or audio recordings.

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

    CrunchzApp::channel()
        ->contact('xxx@c.us')
        ->voice(
            audioUrl: 'https://github.com/CrunchzApp/asset-example/raw/main/examples/julie-voice.opus'
        )
        ->send();
    ```
  </Tab>

  <Tab title="Parameters">
    | Parameter | Type   | Required | Description           |
    | --------- | ------ | -------- | --------------------- |
    | audioUrl  | string | Yes      | URL of the audio file |
  </Tab>
</Tabs>

<Note>
  Supported audio formats include MP3, OGG, and OPUS. For voice messages, OPUS format is recommended for best quality and compression.
</Note>

### Video Messages

Share videos with optional captions.

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

    CrunchzApp::channel()
        ->contact('xxx@c.us')
        ->video(
            videoUrl: 'https://github.com/CrunchzApp/asset-example/raw/main/examples/video.mp4',
            caption: 'Check out this video'
        )
        ->send();
    ```
  </Tab>

  <Tab title="Parameters">
    | Parameter | Type   | Required | Description                         |
    | --------- | ------ | -------- | ----------------------------------- |
    | videoUrl  | string | Yes      | URL of the video file               |
    | caption   | string | No       | Optional text caption for the video |
  </Tab>
</Tabs>

<Warning>
  Supported video formats include MP4 and 3GP. Maximum file size is 16MB with a maximum duration of 3 minutes.
</Warning>

### Polls

Create interactive polls to gather feedback from your contacts.

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

    CrunchzApp::channel()
        ->contact('xxx@c.us')
        ->polling(
            title: 'Survey about iPhone 16',
            options: ['Expensive', 'Cheap', 'Can buy it'],
            isMultipleAnswer: false,
        )
        ->send();
    ```
  </Tab>

  <Tab title="Parameters">
    | Parameter        | Type    | Required | Description                                               |
    | ---------------- | ------- | -------- | --------------------------------------------------------- |
    | title            | string  | Yes      | The question or title of the poll                         |
    | options          | array   | Yes      | Array of answer options (2-12 options)                    |
    | isMultipleAnswer | boolean | No       | Whether multiple options can be selected (default: false) |
  </Tab>
</Tabs>

## Message Management

Control and interact with messages after they've been sent.

### React to Messages

Add emoji reactions to messages.

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

    CrunchzApp::channel()
        ->contact('xxx@c.us')
        ->react(
            messageId: 'false_xxxx@c.us_xxx',
            reaction: '😍'
        )
        ->send();
    ```
  </Tab>

  <Tab title="Parameters">
    | Parameter | Type   | Required | Description                   |
    | --------- | ------ | -------- | ----------------------------- |
    | messageId | string | Yes      | ID of the message to react to |
    | reaction  | string | Yes      | Emoji to use as reaction      |
  </Tab>
</Tabs>

<Note>
  To remove a reaction, set the reaction parameter to an empty string.
</Note>

### Star Messages

Mark important messages with a star for easy reference.

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

    CrunchzApp::channel()
        ->contact('xxx@c.us')
        ->star(
            messageId: 'false_xxxx@c.us_xxx',
            starred: true
        )
        ->send();
    ```
  </Tab>

  <Tab title="Parameters">
    | Parameter | Type    | Required | Description                      |
    | --------- | ------- | -------- | -------------------------------- |
    | messageId | string  | Yes      | ID of the message to star/unstar |
    | starred   | boolean | Yes      | true to star, false to unstar    |
  </Tab>
</Tabs>

### Delete Messages

Remove sent messages from the chat.

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

    CrunchzApp::channel()
        ->contact('xxx@c.us')
        ->delete(
            messageId: 'false_xxxx@c.us_xxx'
        )
        ->send();
    ```
  </Tab>

  <Tab title="Parameters">
    | Parameter | Type   | Required | Description                 |
    | --------- | ------ | -------- | --------------------------- |
    | messageId | string | Yes      | ID of the message to delete |
  </Tab>
</Tabs>

<Warning>
  Messages can only be deleted within a limited time window after sending (typically 1 hour for everyone, or anytime for "delete for me").
</Warning>

### Mark Messages as Seen

Indicate that a message has been read.

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

    CrunchzApp::channel()
        ->contact('xxx@c.us')
        ->seen(
            messageId: 'false_xxxx@c.us_xxx'
        )
        ->send();
    ```
  </Tab>

  <Tab title="Parameters">
    | Parameter | Type   | Required | Description                       |
    | --------- | ------ | -------- | --------------------------------- |
    | messageId | string | Yes      | ID of the message to mark as seen |
  </Tab>
</Tabs>

## Chat Status

Control typing indicators to provide a more natural conversation experience.

### Start Typing Indicator

Show the typing indicator to the recipient.

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

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

<Note>
  The typing indicator automatically disappears after 25 seconds if not manually stopped.
</Note>

### Stop Typing Indicator

Hide the typing indicator.

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

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

## Common Use Cases

<AccordionGroup>
  <Accordion title="Automated Customer Support">
    Use text messages for initial responses, rich media for tutorials, and polls for feedback collection.
  </Accordion>

  <Accordion title="Order Updates">
    Send text notifications with order status, location messages for delivery tracking, and image messages for product photos.
  </Accordion>

  <Accordion title="Interactive Marketing">
    Create engaging campaigns with videos, polls for customer preferences, and typing indicators for a more human-like interaction.
  </Accordion>

  <Accordion title="Educational Content">
    Deliver lessons through a combination of text, images, videos, and voice messages, with polls to test understanding.
  </Accordion>
</AccordionGroup>

## Error Handling

<Tabs>
  <Tab title="Invalid Contact">
    ```json theme={null}
    {
      "success": false,
      "message": "Invalid contact ID or contact not found",
      "error_code": "INVALID_CONTACT"
    }
    ```
  </Tab>

  <Tab title="Media Upload Failed">
    ```json theme={null}
    {
      "success": false,
      "message": "Failed to upload media file",
      "error_code": "MEDIA_UPLOAD_FAILED"
    }
    ```
  </Tab>

  <Tab title="Message Not Found">
    ```json theme={null}
    {
      "success": false,
      "message": "Message ID not found",
      "error_code": "MESSAGE_NOT_FOUND"
    }
    ```
  </Tab>
</Tabs>
