Overview
Svara sends audio messages to Slack channels and direct messages through the Slack Web API. Audio messages appear as playable audio clips in the channel or DM, just like uploading an audio file natively in Slack.
Your Slack Bot acts as the sender. The bot must be added to the target channel before it can send messages there.
Required session data
| Field | Type | Description |
|---|---|---|
| bot_token | string | A Slack Bot User OAuth Token starting with xoxb- |
How to get credentials
1. Create a Slack App
- Go to api.slack.com/apps and click Create New App.
- Choose From scratch and select your workspace.
- Give your app a name (e.g., "Svara Voice Notes").
2. Configure bot permissions
- Navigate to OAuth & Permissions in the sidebar.
- Under Bot Token Scopes, add the following scopes:
chat:write— Send messages to channelsfiles:write— Upload audio files
3. Install to your workspace
- Click Install to Workspace at the top of the OAuth & Permissions page.
- Authorize the requested permissions.
- Copy the Bot User OAuth Token (starts with
xoxb-).
export SLACK_BOT_TOKEN="xoxb-1234567890-1234567890123-abc123xyz456"
4. Add the bot to channels
Before the bot can send messages to a channel, it must be a member:
- Open the target channel in Slack.
- Type
/invite @YourBotNameor click the channel name, go to Integrations, and add your app.
For direct messages, the bot can message any user in the workspace without an invite.
5. Get the channel or user ID
The recipient is a Slack channel ID (starts with C for public channels, G for private channels) or user ID (starts with U for DMs).
To find a channel ID:
- Right-click the channel name in Slack, select View channel details, and find the ID at the bottom.
- Or use the
conversations.listAPI method.
To find a user ID:
- Click on a user's profile and select Copy member ID.
Audio format
Slack supports a wide range of audio formats. Svara sends audio files directly when possible:
| Input format | Behavior | |---|---| | MP3 | Sent directly | | M4A / AAC | Sent directly | | WAV | Sent directly | | OGG / OPUS | Sent directly | | WebM | Auto-converted to MP3 |
Audio files must be under 1 GB (Slack's general file size limit), though practical limits are lower for free workspaces. There is no duration restriction.
Example request
curl -X POST https://api.svarapi.io/v1/send \
-H "Authorization: Bearer $SVARA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"platform": "slack",
"recipient": "C0123456789",
"audio_url": "https://cdn.example.com/notes/update.m4a",
"session": {
"bot_token": "xoxb-1234567890-1234567890123-abc123xyz456"
}
}'
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: "slack",
recipient: "C0123456789",
audio_url: "https://cdn.example.com/notes/update.m4a",
session: {
bot_token: process.env.SLACK_BOT_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": "slack",
"recipient": "C0123456789",
"audio_url": "https://cdn.example.com/notes/update.m4a",
"session": {
"bot_token": bot_token,
},
},
)
result = response.json()
print(f"Voice note queued: {result['id']}")
Common errors
| Error | Cause | Solution |
|---|---|---|
| invalid_bot_token | The bot token is malformed or revoked | Reinstall your Slack app and generate a new token |
| channel_not_found | The channel ID is invalid | Verify the channel ID using Slack's UI or API |
| not_in_channel | The bot has not been added to the target channel | Invite the bot to the channel with /invite @BotName |
| missing_scope | The bot token lacks required permissions | Add chat:write and files:write scopes, then reinstall |
| audio_too_large | The audio file is too large for the workspace plan | Compress your audio or upgrade the Slack workspace |
| audio_fetch_failed | Could not download the audio from the URL | Ensure the URL is publicly accessible |