Sending Voice Message with Python using Sendchamp Voice API

A quick walk-through on how to seamlessly implement Sendchamp Voice API with Python

Aliyu Abubakar

Aug 11, 2021

Learn how to quickly send voice messages with Python using sendchamp API. In this guide we will walk you through:

  1. Signing up free sendchamp account
  2. Setting up your Python Application
  3. Sending your voice message

Prerequisite

Before you can get started, you need the following already set up: You have python installed. If you don't, read about how to install it on your system here.

  • A sendchamp account
  • Signing up free sendchamp account

If you already have an account? skip to the next section You can sign up for a free sendchamp account here.

image

When you sign up, you'll have to verify your email address. This allows sendchamp to verify your identity.

After you've verified your email address, you'll be asked a question in order to get you started in a way that's relevant to you.

After you finish setting up your account, you'll have access to your dashboard where you can access your API Key and perform dashboard communication functions.

Setting up your Python Application

First, you’ll need to create a file voice.py to save your code.


import requests

url = "https://api.sendchamp.com/api/v1/voice/send"

payload="{\n \"customer_mobile_number\": \"2348119974190\",\n    
\"message\": \"Hello from Olumide\",\n 
\"repeat\": 2,\n       
\"type\": \"outgoing\"\n}"
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Bearer SECRET_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Replace URL with either a test or live BASE URL depending on what you intend to do.

Replace Authorization under HEADER with your test or live Access key depending on what you intend to do.

Parameters

  • Set the value of (customer_phone_number) to any number (or numbers) you want to receive the message.
  • Set the value of the type to incoming for incoming messages and set type to outgoing for outgoing messages.
  • Set (message)to text message you want to send as a voice message.

Sending your voice message

Now you can execute the code and send your test your voice message.

Run the following script:

voice.py 

The code you used in the voice.py file sends a POST request to the sendchamp API endpoint to send your voice message.

© 2022 Sendchamp. All rights reserved.