Send Voice
Send voice messages (audio recordings) to a chat.
Usage
The Message facade's sendVoice method may be used to send a voice message to a chat.
php
use NjoguAmos\Waha\Facades\Message;
use NjoguAmos\Waha\Dto\MessageVoiceData;
$data = new MessageVoiceData(
chatId: '[email protected]',
file: 'https://example.com/voice.opus',
);
/** @var \Saloon\Http\Response $response */
$response = Message::sendVoice(data: $data);php
use NjoguAmos\Waha\Facades\Message;
use NjoguAmos\Waha\Dto\MessageVoiceData;
$data = new MessageVoiceData(
chatId: '[email protected]',
file: 'data:audio/ogg;base64,base64-encoded-data...',
);
/** @var \Saloon\Http\Response $response */
$response = Message::sendVoice(data: $data);php
use NjoguAmos\Waha\Facades\Message;
use NjoguAmos\Waha\Dto\MessageVoiceData;
$data = new MessageVoiceData(
chatId: '[email protected]',
file: 'https://example.com/voice.opus',
reply_to: '[email protected]_AAA',
);
/** @var \Saloon\Http\Response $response */
$response = Message::sendVoice(data: $data);Voice File Format
WhatsApp accept only file with OPUS encoding and packed in OGG container.
If you have a file in a different format (like mp3) you can use the convert: true option to have WAHA convert it for you automatically.
Response
The response returned by the sendVoice method is an instance of Saloon\Http\Response. You may use the json method to retrieve the response as an array:
php
/** @var \Saloon\Http\Response $response */
$response->status(); // 201
$response->json(); // ["id" => "[email protected]_BAE6A33293978B16", "timestamp" => 1629200000, ...]php
use NjoguAmos\Waha\Facades\Message;
use NjoguAmos\Waha\Dto\MessageVoiceData;
$data = new MessageVoiceData(
chatId: '[email protected]',
file: 'https://example.com/voice.opus',
);
/** @var \Saloon\Http\Response $response */
$response = Message::sendVoice(data: $data);
$json = $response->json();Engines
| WEBJS | WPP | NOWEB | GOWS |
|---|---|---|---|
| ➕ | ➕ | ➕ | ➕ |