Messenger Voice Notes

Send Facebook Messenger voice messages through the Meta Send API using Svara.

Overview

Svara sends native voice messages on Facebook Messenger through the Meta Send API. Voice notes appear as playable audio bubbles in the recipient's Messenger conversation, identical to messages recorded directly in the app.

Your Facebook Page acts as the sender. The recipient must have an existing conversation with your Page or have interacted with it before you can send them messages.

Required session data

| Field | Type | Description | |---|---|---| | page_access_token | string | A Page Access Token with the pages_messaging permission |

How to get credentials

1. Create a Meta App

  1. Go to developers.facebook.com and create a new app.
  2. Select Business as the app type.
  3. Add the Messenger product to your app.

2. Connect your Facebook Page

  1. In your app's Messenger settings, click Add or Remove Pages.
  2. Select the Facebook Page you want to send messages from.
  3. Grant the required permissions.

3. Generate a Page Access Token

  1. In the Messenger settings, find your connected Page.
  2. Click Generate Token next to it.
  3. Copy the token and store it securely.
export META_PAGE_TOKEN="EAAGm0PX4ZCps..."

For production use, exchange this for a long-lived token that does not expire.

4. Get the recipient's PSID

The recipient is identified by their Page-Scoped ID (PSID) — a unique identifier for each user relative to your Page. You receive PSIDs when users message your Page, through webhooks, or from the Conversations API.

Audio format

Messenger voice messages use M4A (AAC) format. Svara handles conversion automatically:

| Input format | Behavior | |---|---| | M4A / AAC | Sent directly, no conversion needed | | MP3 | Auto-converted to M4A/AAC | | OGG / OPUS | Auto-converted to M4A/AAC | | WAV | Auto-converted to M4A/AAC | | WebM | Auto-converted to M4A/AAC |

Audio files must be under 25 MB. There is no strict duration limit, but shorter messages (under 2 minutes) are recommended for the best user experience.

Example request

curl -X POST https://api.svarapi.io/v1/send \
  -H "Authorization: Bearer $SVARA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "messenger",
    "recipient": "6128493027184956",
    "audio_url": "https://cdn.example.com/notes/update.m4a",
    "session": {
      "page_access_token": "EAAGm0PX4ZCps..."
    }
  }'
const response = await fetch("https://api.svarapi.io/v1/send", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.SVARA_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    platform: "messenger",
    recipient: "6128493027184956",
    audio_url: "https://cdn.example.com/notes/update.m4a",
    session: {
      page_access_token: process.env.META_PAGE_TOKEN,
    },
  }),
});

const result = await response.json();
console.log(`Voice note queued: ${result.id}`);
import requests

response = requests.post(
    "https://api.svarapi.io/v1/send",
    headers={"Authorization": f"Bearer {api_key}"},
    json={
        "platform": "messenger",
        "recipient": "6128493027184956",
        "audio_url": "https://cdn.example.com/notes/update.m4a",
        "session": {
            "page_access_token": page_token,
        },
    },
)

result = response.json()
print(f"Voice note queued: {result['id']}")

Common errors

| Error | Cause | Solution | |---|---|---| | invalid_token | The Page Access Token is expired or malformed | Generate a new token in your Meta App's Messenger settings | | recipient_not_found | The PSID is invalid or does not belong to your Page | Verify the PSID came from an interaction with your Page | | message_not_allowed | The user has not messaged your Page or the 24-hour window has closed | The user must re-initiate a conversation with your Page | | audio_too_large | The audio file exceeds 25 MB | Compress or shorten your audio | | audio_fetch_failed | Could not download the audio from the URL | Ensure the URL is publicly accessible | | rate_limited | Too many messages sent in a short period | Reduce send frequency and retry after a brief pause |

Ask Svara

Hey! I'm the Svara assistant. Ask me anything about integrating voice notes into your product.

Powered by Svara