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.

use CrunchzApp\CrunchzApp;

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

Text messages support markdown formatting for bold, italic, strikethrough, and code blocks.

Image Messages

Share images with optional captions.

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();

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

Location Messages

Share geographic locations with your contacts.

use CrunchzApp\CrunchzApp;

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

Voice Messages

Send voice or audio recordings.

use CrunchzApp\CrunchzApp;

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

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

Video Messages

Share videos with optional captions.

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();

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

Polls

Create interactive polls to gather feedback from your contacts.

use CrunchzApp\CrunchzApp;

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

Message Management

Control and interact with messages after theyโ€™ve been sent.

React to Messages

Add emoji reactions to messages.

use CrunchzApp\CrunchzApp;

CrunchzApp::channel()
    ->contact('xxx@c.us')
    ->react(
        messageId: 'false_xxxx@c.us_xxx',
        reaction: '๐Ÿ˜'
    )
    ->send();

To remove a reaction, set the reaction parameter to an empty string.

Star Messages

Mark important messages with a star for easy reference.

use CrunchzApp\CrunchzApp;

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

Delete Messages

Remove sent messages from the chat.

use CrunchzApp\CrunchzApp;

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

Messages can only be deleted within a limited time window after sending (typically 1 hour for everyone, or anytime for โ€œdelete for meโ€).

Mark Messages as Seen

Indicate that a message has been read.

use CrunchzApp\CrunchzApp;

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

Chat Status

Control typing indicators to provide a more natural conversation experience.

Start Typing Indicator

Show the typing indicator to the recipient.

use CrunchzApp\CrunchzApp;

CrunchzApp::channel()
    ->contact('xxx@c.us')
    ->startTyping()
    ->send();

The typing indicator automatically disappears after 25 seconds if not manually stopped.

Stop Typing Indicator

Hide the typing indicator.

use CrunchzApp\CrunchzApp;

CrunchzApp::channel()
    ->contact('xxx@c.us')
    ->stopTyping()
    ->send();

Common Use Cases

Error Handling

{
  "success": false,
  "message": "Invalid contact ID or contact not found",
  "error_code": "INVALID_CONTACT"
}