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

# Parallel & Single

> Methods for sending messages through the CrunchzApp WhatsApp API

## Overview

The CrunchzApp SDK provides two distinct methods for sending WhatsApp messages, each designed for different use cases and requirements. Understanding the differences between these methods will help you implement the most efficient messaging strategy for your application.

## Message Sending Methods

### Parallel Method

The Parallel method allows you to stack multiple operations and send them as a batch. This approach is ideal when you want to:

* Create a natural messaging flow with typing indicators
* Send multiple messages in sequence
* Combine different types of actions in a single request

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

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

  <Tab title="Controller Example">
    ```php theme={null}
    namespace App\Http\Controllers;

    use CrunchzApp\CrunchzApp;

    class TestController extends Controller
    {
        /**
         * @throws \Exception
         */
        public function index()
        {
            return CrunchzApp::channel()
                ->contact('6281357541790@c.us')
                ->startTyping()
                ->text('This is a message from you')
                ->text('Another text message from me')
                ->stopTyping()
                ->sendPool();
        }
    }
    ```
  </Tab>

  <Tab title="Key Points">
    | Feature      | Description                                  |
    | ------------ | -------------------------------------------- |
    | Method Chain | Stack multiple operations before sending     |
    | Final Method | Use `->sendPool()` to execute all operations |
    | Execution    | All operations are sent in a single batch    |
    | Best For     | Creating natural conversation flows          |
  </Tab>
</Tabs>

<Note>
  The Parallel method executes all operations in the order they are chained, making it perfect for simulating natural conversation patterns with typing indicators.
</Note>

### Single Method

The Single method executes each operation immediately when the `->send()` method is called. This approach is ideal when you want to:

* Send individual messages with immediate execution
* Handle responses for each message separately
* Implement conditional logic between messages

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

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

    // Send another message
    CrunchzApp::channel()
        ->contact('xxx@c.us')
        ->text('Another text message')
        ->send();
    ```
  </Tab>

  <Tab title="With Typing Indicators">
    ```php theme={null}
    use CrunchzApp\CrunchzApp;

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

    // Wait for a moment to simulate typing
    sleep(2);

    // Send the message
    CrunchzApp::channel()
        ->contact('xxx@c.us')
        ->text('This is a message after typing')
        ->send();

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

  <Tab title="Key Points">
    | Feature      | Description                             |
    | ------------ | --------------------------------------- |
    | Method Chain | Each operation is sent individually     |
    | Final Method | Use `->send()` to execute the operation |
    | Execution    | Each operation is sent immediately      |
    | Best For     | Independent messages with custom timing |
  </Tab>
</Tabs>

<Warning>
  When using the Single method, each operation requires a separate API call, which may impact performance if you're sending many messages in sequence.
</Warning>

## Choosing Between Methods

<AccordionGroup>
  <Accordion title="When to Use Parallel Method">
    * When simulating natural conversation with typing indicators
    * When sending a sequence of related messages
    * When you want to minimize the number of API calls
    * When the entire message sequence is predetermined
  </Accordion>

  <Accordion title="When to Use Single Method">
    * When you need to process responses between messages
    * When implementing conditional logic based on previous message status
    * When messages need to be sent with specific timing
    * When working with user interactions that trigger individual messages
  </Accordion>

  <Accordion title="Performance Considerations">
    The Parallel method is generally more efficient for sending multiple messages as it requires only one API call. The Single method makes a separate API call for each message, which may be less efficient but offers more flexibility.
  </Accordion>
</AccordionGroup>
