Skip to main content

Custom SMS Connector Guide

SMS Connector is a flexible, standardized interface for sending and receiving SMS and MMS messages on PBXware using custom SMS trunks. Available since PBXware 7.2, it lets you connect PBXware's SMS Service to any SMS provider - including providers not natively supported - by building a middleware application.


How It Works

The SMS Connector sits between PBXware and your SMS provider. Your middleware handles both directions:

Outbound: gloCOM → PBXware → [Your Middleware] → SMS Provider
Inbound: SMS Provider → [Your Middleware] → PBXware → gloCOM
  1. Configure a Custom trunk - point PBXware at your middleware's Webhook URL and set a shared Auth Token
  2. Outbound messages - PBXware POSTs each outgoing SMS to your Webhook URL; your middleware forwards it to the provider
  3. Inbound messages - your middleware receives messages from the provider and POSTs them to PBXware's /smsservice/connector endpoint

Prerequisites

  • PBXware 7.2 or later
  • SMS Connector feature enabled in your PBXware license
  • A middleware application with a publicly reachable HTTPS endpoint

Configure a Custom SMS Trunk

Multi-Tenant Edition: System → SMS → Trunks → Add SMS Trunk

CC/Business Edition: SMS → Trunks → Add SMS Trunk

FieldDescription
EnableToggle to enable or disable the trunk
NameDisplay name for the trunk (e.g. Custom SMS Provider)
ProviderSelect Custom from the dropdown
Webhook URLURL of your middleware - PBXware POSTs outbound messages here
Auth TokenShared secret used to authenticate requests between PBXware and your middleware. Enter manually or generate one using the icon on the right.
DescriptionOptional notes for administrators

Note: The Custom option only appears in the Provider dropdown when the SMS Connector feature is enabled in your PBXware license.

Click Save to create the trunk. Once the middleware is operational, the custom trunk works identically to any other SMS trunk on PBXware.


API Reference

Outbound: PBXware → Middleware

When a user sends an SMS via gloCOM, PBXware POSTs to your Webhook URL:

POST {webhook_url}
Content-Type: application/json
Authorization: Bearer {auth_token}
{
"from": "string",
"to": "string",
"text": "string",
"media_urls": ["string"]
}
FieldDescription
fromSender's phone number
toRecipient's phone number
textMessage content
media_urlsMedia attachment URLs (MMS); empty array for SMS

Your middleware must respond with one of:

{ "status": "success", "message": "" }
{ "status": "error", "message": "description of what went wrong" }

Note: Any HTTP response status other than 200 causes PBXware to treat the message as failed.


Inbound: Middleware → PBXware

To deliver a message received from the provider into PBXware, POST to:

POST /smsservice/connector
Content-Type: application/json
Authorization: Bearer {auth_token}
{
"from": "string",
"to": "string",
"text": "string",
"media_urls": ["string"]
}
StatusMeaning
200 OKSMS received successfully
401 UnauthorizedMissing or invalid Auth Token
500 Internal Server ErrorServer-side error - details in response body

Examples

Outbound Handler (PBXware → Middleware → Provider)

Accepts outbound messages from PBXware, validates the Auth Token, and forwards to your SMS provider.

Install: npm install express

import express from 'express';

const AUTH_TOKEN = process.env.AUTH_TOKEN ?? 'YOUR_AUTH_TOKEN';

const app = express();
app.use(express.json());

function sendMessageToProvider(messageData) {
// Replace with actual provider integration
console.log('Forwarding to provider:', messageData);
return { status: 'success', message: '' };
}

app.post('/messages', (req, res) => {
try {
const authHeader = req.headers['authorization'] ?? '';
if (authHeader !== `Bearer ${AUTH_TOKEN}`) {
return res.status(401).json({ status: 'error', message: 'Unauthorized' });
}
if (req.headers['content-type'] !== 'application/json') {
return res.status(400).json({ status: 'error', message: 'Invalid content type' });
}
const result = sendMessageToProvider(req.body);
res.json(result);
} catch (e) {
res.status(500).json({ status: 'error', message: e.message });
}
});

app.listen(5000, () => console.log('Server running on http://localhost:5000'));

Inbound Handler (Provider → Middleware → PBXware)

Accepts messages from your SMS provider, maps the provider's field names to PBXware's format, and forwards to PBXware.

Install: npm install express node-fetch

import express from 'express';
import fetch from 'node-fetch';

const PBXWARE_URL = 'https://my.pbxware.com/smsservice/connector';
const AUTH_TOKEN = process.env.AUTH_TOKEN ?? 'YOUR_AUTH_TOKEN';

const app = express();
app.use(express.json());

function parseProviderRequest(body) {
return {
from: body.sender_number ?? '',
to: body.recipient_number ?? '',
text: body.message_content ?? '',
media_urls: body.media_urls ?? [],
};
}

app.post('/messages', async (req, res) => {
try {
if (req.headers['content-type'] !== 'application/json') {
return res.status(400).json({ status: 'error', message: 'Invalid content type' });
}
const formatted = parseProviderRequest(req.body);
const response = await fetch(PBXWARE_URL, {
method: 'POST',
headers: {
'Authorization': `Bearer ${AUTH_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(formatted),
});
if (response.ok) {
res.json({ status: 'success', message: 'Message sent successfully' });
} else {
const text = await response.text();
res.status(response.status).json({ status: 'error', message: `Failed to send message. Error: ${text}` });
}
} catch (e) {
res.status(500).json({ status: 'error', message: e.message });
}
});

app.listen(5001, () => console.log('Server running on http://localhost:5001'));

Running the Server

Save as server.mjs (or .js with "type": "module" in package.json), then:

AUTH_TOKEN=your_secret_token node server.mjs

Tip: Replace YOUR_AUTH_TOKEN with the Auth Token configured on the PBXware trunk, or set it via the AUTH_TOKEN environment variable. Both middleware servers must use the same token as configured in PBXware.