Viber Voice Notes

Send Viber voice messages through the Viber Business Messages API using Svara.

Overview

Svara sends voice messages on Viber through the Viber Business Messages API. Voice messages appear as playable audio in the recipient's Viber conversation, the same as recording a voice message directly in the app.

Your Viber Bot (also called a Viber Business Account) acts as the sender. The recipient must have subscribed to your bot before you can send them messages.

Required session data

| Field | Type | Description | |---|---|---| | auth_token | string | Your Viber Bot authentication token |

How to get credentials

1. Create a Viber Bot

  1. Go to the Viber Admin Panel and sign in.
  2. Click Create Bot Account.
  3. Fill in the required details (name, icon, category).
  4. Once created, you will receive an authentication token.
export VIBER_AUTH_TOKEN="4dc7a8e1b0f3c9d2-1234abcd5678efgh-9012ijkl3456mnop"

2. Set up a webhook

Viber requires an active webhook to receive events. Set it up to start receiving subscriber information:

curl -X POST https://chatapi.viber.com/pa/set_webhook \
  -H "X-Viber-Auth-Token: $VIBER_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://your-app.com/viber/webhook"}'

3. Get the recipient's user ID

The recipient is identified by their Viber user ID — a unique string you receive when a user subscribes to your bot or sends you a message. User IDs are delivered through your webhook.

Common ways to get user IDs:

  • From the subscribed webhook event when a user starts a conversation with your bot.
  • From incoming message webhook events.
  • From the get_account_info API response which lists subscribers.

Audio format

Viber supports multiple audio formats. Svara handles conversion automatically:

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

Audio files must be under 50 MB. There is no strict duration limit, but messages under 2 minutes work best for the playback 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": "viber",
    "recipient": "dG9KQ2FVbHk0a2plaQ==",
    "audio_url": "https://cdn.example.com/notes/update.m4a",
    "session": {
      "auth_token": "4dc7a8e1b0f3c9d2-1234abcd5678efgh-9012ijkl3456mnop"
    }
  }'
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: "viber",
    recipient: "dG9KQ2FVbHk0a2plaQ==",
    audio_url: "https://cdn.example.com/notes/update.m4a",
    session: {
      auth_token: process.env.VIBER_AUTH_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": "viber",
        "recipient": "dG9KQ2FVbHk0a2plaQ==",
        "audio_url": "https://cdn.example.com/notes/update.m4a",
        "session": {
            "auth_token": auth_token,
        },
    },
)

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

Common errors

| Error | Cause | Solution | |---|---|---| | invalid_auth_token | The authentication token is malformed or revoked | Generate a new token in the Viber Admin Panel | | recipient_not_found | The user ID is invalid or the user has not subscribed to your bot | The user must subscribe to your bot first by opening a conversation | | recipient_not_subscribed | The user unsubscribed from your bot | The user needs to re-subscribe by messaging your bot | | audio_too_large | The audio file exceeds 50 MB | Compress or shorten your audio | | audio_fetch_failed | Could not download the audio from the URL | Ensure the URL is publicly accessible | | webhook_not_set | No webhook URL configured for your bot | Set up a webhook using the Viber API before sending messages |

Ask Svara

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

Powered by Svara