Create an Audio Message and Share it on Slack

See how it is done!

1. Create your Slack account

Go to and click on Sign up


Already have a Slack account?

You're all set! Move on to step 2

2. Create your Slack app and set it up

1️⃣ Log into your Slack account, and select select the Slack Workspace to send messages to
2️⃣ Go to and click on Create a custom app
3️⃣ Choose a name and a Development Slack Workspace and click on Create App
4️⃣ On the left menu click on OAuth & Permissions and under "Bot Token Scopes" select Add an OAuth Scope. Select "files:write", "groups:write" and "chat:write".
5️⃣ Scroll up and click on Install to Workspace and Allow. Copy the Bot User OAuth Token.
6️⃣ Now, in Slack Workspace, find the group you want to send the audio message to and copy&paste: /invite @your_App_name.
Now we can start coding!

3. Create your audio file with the

1️⃣ Obtain and import your API key
2️⃣ Create and download a voice clip from text with


Customise your script text and choose your favourite speaker and background track!

import apiaudio

apiaudio.api_key = "YOUR_API_KEY"

def apiaudio_create(scriptName, message):
    script = apiaudio.Script().create(scriptText= message, scriptName=scriptName, moduleName="hello_world", projectName="hello_world")
    response = apiaudio.Speech().create(scriptId=script.get("scriptId"), voice="Joanna")
    response = apiaudio.Mastering().create(scriptId=script.get("scriptId"),soundTemplate="heatwave")
    file = apiaudio.Mastering().download(scriptId=script.get("scriptId"), destination=".")
    file = apiaudio.Mastering().retrieve(scriptId=script.get("scriptId"))
    return file["url"]
apiaudio_create("hello_world", "Enjoy the Api! Write any message here!")
const Aflr = require("aflr").default;

const api_key = "YOUR_API_KEY";

const fileName = "";
const url_mp3 = "";

async function aflr_create(fileName) {
  try {
    Aflr.configure({ apiKey: api_key });
    let script = await Aflr.Script.create({
      scriptText: "Hey, Is it working??",
      proyectName: "Working_with_recipes",
      moduleName: "recipes",
      scriptName: fileName,
    script = await Aflr.Script.retrieve(script["scriptId"]);

    let scripts = await Aflr.Script.list();

    let voices = await Aflr.Voice.list();

    let speech = await Aflr.Speech.create({ scriptId: script["scriptId"] });

    let speechResult = await Aflr.Speech.retrieve(script["scriptId"]);

    let bg_tracks = await Aflr.Sound.list();

    let mastering = await Aflr.Mastering.create({
      scriptId: script["scriptId"],
      backgroundTrackId: bg_tracks[4]["id"],

    let masteringResult = await Aflr.Mastering.retrieve(script["scriptId"], {});
    url_mp3 = masteringResult.url;
    return url_mp3;
  } catch (e) {

// Use the following function to download the mp3 from the url retrieved
const https = require("https");
const fs = require("fs");

async function downloadUrl(url_mp3) {
  try {
    const req = https.get(url_mp3, function (res) {
      const fileStream = fs.createWriteStream(fileName.concat(".mp3"));
      fileStream.on("finish", function () {
  } catch (e) {

4. Send a message to the Slack channel with a file attached!


The following sample code is given by the Slack API documentation. More information:

1️⃣Paste in the Bot User OAuth Token.
2️⃣Choose your target channel. (At the channel variable, it is possible to write the name of the channel or its id. More information about how to find the id here:

# Script to send files
# Documentation:
import os
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError

client = WebClient("insert your token here")

    response = client.files_upload(channels='your_target_channel', initial_comment = "Hey! Listen to what I created for you :smile:", file=filepath)
    assert response["file"]
except SlackApiError as e:
    assert e.response["ok"] is False
    assert e.response["error"]
    print(f"Got an error: {e.response['error']}")
// Documentation:

const { createReadStream } = require("fs");
const { WebClient, LogLevel } = require("@slack/web-api");
const client = new WebClient("insert-your-token-here", {
  logLevel: LogLevel.DEBUG,

const fileName = "./default.mp3";
const channel = "your_target_channel";

async function SlackCall() {
  try {
    const result = await client.files.upload({
      // channels can be a list of one to many strings
      channels: channel,
      initial_comment: "Hey! Click here to download the audio :smile:",
      file: createReadStream(fileName),
  } catch (error) {