📞 Send Voice Notifications

This guide will get you sending voice call notifications quickly with NotificationAPI. Here’s how.

INFO

You DON’T need another 3rd-party like Twilio. Through our partnerships, we allocate and manage any required telecom infrastructure for you.

Install the SDK:

npm install notificationapi-node-server-sdk
pip install notificationapi_python_server_sdk
composer require notificationapi/notificationapi-php-server-sdk
go get github.com/notificationapi-com/notificationapi-go-server-sdk
dotnet add package NotificationAPI --version 0.5.0

Add the following dependencies to your pom.xml file:

<dependencies>
    <dependency>
        <groupId>com.notificationapi</groupId>
        <artifactId>notificationapi-java-server-sdk</artifactId>
        <version>0.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.14</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.15.2</version>
    </dependency>
</dependencies>

Add the NotificationAPI class to your application - see the full Ruby implementation.

Now, send an automated call notification from your backend:

TIP

Replace YOUR_CLIENT_ID and YOUR_CLIENT_SECRET with the values from the code sample in your NotificationAPI dashboard. These values can also be found in the Environments section of the dashboard.

import notificationapi from 'notificationapi-node-server-sdk';

// Initialize (default US region)
// For CA region: add 'https://api.ca.notificationapi.com' after CLIENT_SECRET
// For EU region: add 'https://api.eu.notificationapi.com' after CLIENT_SECRET
notificationapi.init('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET');

// Send call notification (direct content)
notificationapi.send({
  type: 'urgent_alert',
  to: {
    id: 'user123',
    number: '+16175551212' // Replace using format [+][country code][area code][local number]
  },
  call: {
    message: 'This is an urgent alert from Acme Corp.'
  }
});
import asyncio
from notificationapi_python_server_sdk import notificationapi

# Initialize (default US region)
notificationapi.init("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET")

async def send_call():
    await notificationapi.send({
        "type": "urgent_alert",
        "to": {
            "id": "user123",
            "number": "+16175551212"  # Replace using format [+][country code][area code][local number]
        },
        "call": {
            "message": "This is an urgent alert from Acme Corp."
        }
    })

# Run the async function
asyncio.run(send_call())
use NotificationAPI\NotificationAPI;

// Initialize
$notificationapi = new NotificationAPI('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET');

// Send call notification (direct content)
$notificationapi->send([
    "type" => "urgent_alert",
    "to" => [
        "id" => "user123",
        "number" => "+16175551212"  // Replace using format [+][country code][area code][local number]
    ],
    "call" => [
        "message" => "This is an urgent alert from Acme Corp."
    ]
]);
package main

import (
    notificationapi "github.com/notificationapi-com/notificationapi-go-server-sdk"
)

func main() {
    // Initialize
    notificationapi.Init("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", "https://api.notificationapi.com")

    // Send call notification (direct content)
    notificationapi.Send(
        notificationapi.SendRequest{
            Type: "urgent_alert",
            To: notificationapi.User{
                Id:     "user123",
                Number: "+16175551212",  // Replace using format [+][country code][area code][local number]
            },
            Call: map[string]interface{}{
                "message": "This is an urgent alert from Acme Corp.",
            },
        },
    )
}
using NotificationApi.Server;
using NotificationApi.Server.Models;

// Initialize
var notificationApi = new NotificationApiServer("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");

// Send call notification (direct content)
var notification = new SendNotificationData
{
    Type = "urgent_alert",
    To = new User
    {
        Id = "user123",
        Number = "+16175551212"  // Replace using format [+][country code][area code][local number]
    },
    Call = new Dictionary<string, object>
    {
        { "message", "This is an urgent alert from Acme Corp." }
    }
};

await notificationApi.Send(notification);
package com.example;

import com.notificationapi.NotificationApi;
import com.notificationapi.model.*;

public class Example {
    public static void main(String[] args) {
        NotificationApi api = new NotificationApi(
            "YOUR_CLIENT_ID",
            "YOUR_CLIENT_SECRET"
        );

        // Create user
        User user = new User("user123")
            .setNumber("+16175551212"); // Replace with your phone number, use format [+][country code][area code][local number];

        // Create and send notification request
        NotificationRequest request = new NotificationRequest("urgent_alert", user)
            .setCall(new CallOptions()
                .setMessage("This is an urgent alert from Acme Corp.")
            );

        System.out.println("Sending notification request...");
        String response = api.send(request);
        System.out.println("Response: " + response);
    }
}
# Initialize
notificationapi = NotificationAPI.new("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET")

# Send call notification
notificationapi.send({
  type: "urgent_alert",
  to: {
    id: "user123",
    number: "+16175551212"  # Required for call notifications (E.164 format)
  },
  parameters: {
    firstName: "John",
    alertType: "Security Alert"
  }
})

You’re All Set!

🎉 Congrats! You’re now sending automated voice call notifications!

For more advanced features like sender phone numbers, delivery tracking, and regulatory compliance, check out our Automated Voice Calls Channel documentation.