EmpireUC: texting (SMS and MMS) API - Empire Telecom

EmpireUC: texting (SMS and MMS) API

Empire Telecom · EmpireUC developers

Send and receive texts and pictures from your EmpireUC numbers in your own software.

Open Phones in the portal →Where: Sign in at empiretelecom.io/phones with your portal login.
Direct link: https://empiretelecom.io/phones/

Send and receive texts (SMS) and picture messages (MMS) from your EmpireUC business numbers in your own software: a patient reminder system, a CRM, a front-desk app. Texts you send this way show up in the same conversation in the EmpireUC apps and the Phones portal, so your team sees the whole thread.

Tip: Just want texts to reach a person or a chat app? You do not need code: set an alert on Text message received (see Alerts and webhooks), or use the Incoming text start in a call flow.

At a glance

ItemDetail
APIThe EmpireUC phone system API (REST, JSON over HTTPS). Sign-in, base address and keys are in the API specification
Base addresshttps://<your-EmpireUC-API-server>/ns-api/v2 (Empire Telecom gives you the server address)
AuthenticationAuthorization: Bearer <token or API key>
Who sendsA user (extension) that has a text-enabled number. Messages are filed under that user
Message typessms (text, up to 1,600 characters, sent in parts by the carrier) and mms (JPG, PNG or GIF, up to 1.5 MB)
Group textsUp to 10 recipients in one conversation
Incoming textsPushed to you by webhook (alert rule or event subscription), or read from the conversation list
Business texting rulesNumbers must be registered for A2P 10DLC (US carriers). Empire Telecom handles the registration with you

Before you start

1Ask Empire Telecom to enable texting on the numbers you want to use and register them for business texting (10DLC). Unregistered numbers are blocked by US carriers.
2Get API access for the user (extension) that will send the texts. See Getting access.
3Find your domain and the user's extension. GET /domains/~ returns your domain; the extension is the user's number in the portal.

1. See which numbers can text

Lists the text-enabled numbers this user can send from, and whether each can send pictures.

curl -s "https://<server>/ns-api/v2/domains/{domain}/users/{extension}/smsnumbers" \ -H "Authorization: Bearer $TOKEN"

Each row has number and mms-capable (yes or no). Use the number exactly as returned (digits only, for example 17325550100).

2. Send a text

Messages live in conversations (message sessions). To start a new conversation, make up an ID yourself (any random string of letters and numbers, 32 characters works well) and send to it. To reply in an existing conversation, reuse its ID.

curl -s -X POST \ "https://<server>/ns-api/v2/domains/{domain}/users/{extension}/messagesessions/{conversation-id}/messages" \ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '{ "type": "sms", "message": "Hi Pat, this is Sunrise Senior Living confirming your tour tomorrow at 10 AM. Reply STOP to opt out.", "destination": "12125550100", "from-number": "17325550100" }'
FieldRequiredWhat it is
typeYessms or mms
messageYes for smsThe text. Up to 1,600 characters
destinationYesThe number to text, digits only with country code (12125550100). For a group text, a list of up to 10 numbers: ["12125550100","19175550101"]
from-numberYesOne of the user's text-enabled numbers from step 1
dataMMS onlyThe picture, base64 encoded
mime-typeMMS onlyimage/jpeg, image/png or image/gif
sizeMMS onlyThe picture size in bytes (under 1,500,000)

Send a picture (MMS)

IMG=$(base64 -w0 flyer.jpg) curl -s -X POST "https://<server>/ns-api/v2/domains/{domain}/users/{extension}/messagesessions/{conversation-id}/messages" \ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d "{\"type\":\"mms\",\"message\":\"Our new menu\",\"destination\":\"12125550100\",\"from-number\":\"17325550100\",\"data\":\"$IMG\",\"mime-type\":\"image/jpeg\",\"size\":$(stat -c%s flyer.jpg)}"

3. Read conversations and messages

# Every conversation for this user, newest first curl -s "https://<server>/ns-api/v2/domains/{domain}/users/{extension}/messagesessions?limit=200" -H "Authorization: Bearer $TOKEN" # The messages in one conversation curl -s "https://<server>/ns-api/v2/domains/{domain}/users/{extension}/messagesessions/{conversation-id}/messages?limit=300" -H "Authorization: Bearer $TOKEN" # Every conversation in the account (admin access) curl -s "https://<server>/ns-api/v2/domains/{domain}/messagesessions" -H "Authorization: Bearer $TOKEN"
Conversation fieldMeaning
messagesession-idThe conversation ID (use it to reply)
messagesession-remoteThe other person or people
messagesession-sms-numberYour number in the conversation
messagesession-last-messageThe latest text
messagesession-last-datetimeWhen it was sent
Message fieldMeaning
idThe message ID
timestampWhen it was sent or received
directionIn or out
from-numberWho sent it
terminating-numberWho received it
textThe text (a picture arrives as a link here)
media-typeSet when it is a picture
statusDelivery status

4. Get incoming texts the moment they arrive

Do not poll. Choose one:

  • No code: in Phones > Alerts, make a rule with the event Text message received and add your web address under Send to > Webhook. Each text arrives as a signed JSON post (event message.received). Details in Alerts and webhooks.
  • API: create an event subscription for the message model with POST /subscriptions (see the Webhooks and events section of the API specification).

Rules that keep your texts delivered

  • Opt-in and opt-out: only text people who agreed to it, and honour STOP. The call flow Check consent step can do this for you.
  • Identify yourself in the first message (your business name).
  • No shortened links from public shorteners: carriers often block them.
  • Pace bulk sends: about one text per second per number. For campaigns, ask us about the right setup first.

Errors

What you seeWhat to do
401The token expired: refresh it, or check the API key
403This user cannot text from that number, or the number is not text-enabled
400Check the number format (digits with country code), message length and picture type and size
Sent but never deliveredUsually a 10DLC registration issue. Contact Empire Telecom with the number and time

More

Need a hand? Call Empire Telecom support at (732) 363-9898, email support@empiretelecomnj.com, or open a ticket in the customer portal.