Receive incoming SMS
Prerequisites
In order to receive incoming calls to our system and then forward them to your callback URL, you need a virtual number. You can easily get a virtual number by ordering one of our subscription, or order the additional service 11-digit virtual number in our webshop.
Description
If an incoming SMS callback URL is specified in the account settings, incoming SMS messages will be sent to that URL when available. The content of these SMS messages is described below.
Our system sends incoming SMS with POST and expects a 200 OK if the SMS is delivered correctly. If any other status (ie an error status) is received, the incoming SMS will be re-sent at a later time.
You manage your callback url in the user portal https://portal.ip1.net/ → SMS → Settings for incoming SMS
Callback Payload
{ "id": "5c613848879973045cf39ac4", "batchId": "5c613848879973045cf39ac3", "owner": "ip1-XXXXX", "sender": "46712345678", "recipient": "456189040623", "body": "Hi my name is earl", "direction": "mo", "segments": 1, "type":"SMS", "datacoding": "GSM", "priority": 1, "statuses": [ { "created" : "2018-10-23T17:43:21Z", "code": 201, "duration": 1 } ], "modified": "2018-10-23T17:43:19Z", "mcc": "431" , "mnc": "20" }
Fields for payload
| Field name | Type | Description and Conditions | Example |
|---|---|---|---|
| id | String |
The ID of the incoming message. |
|
| batchId | String |
ID of the parent batch of the incoming message (Messages cannot exist without a parent batch). |
|
| batchId | String |
The account ID of the SMS account that owns the message (e.g. you). |
|
| sender | String |
The sender ID of the message's originator. |
|
| sender | String |
The recipient of the message (your virtual number). |
|
| body | String |
The message contents. |
|
| direction | String |
Indicates whether the message was sent or received by our system.
|
|
| segments | Integer |
In cases where the message consists of more characters than the character limit for one SMS, the message will be split into several SMS, also called concatenated SMS. This property indicates how many SMS are needed to send the message |
|
| type | String |
There are two types: sms and flash.
sms.
|
|
| datacoding | String |
There are two types available:.
gsm is set, messages that require ucs (extended characters) to be denied.
The default is ucs.
|
|
| priority | Integer |
Used for messages that need to be delivered quickly. Allowed values are Setting priorities |
|
| statuses | Array |
An array of status updates.
|
|
| modified | String |
When the SMS was last updated. |
|
| mcc | String |
The country part of the leaf operator may be specified here if it's provided by the upstream carrier. MCC is an
acronym for Mobile Country Code
|
|
| mnc | String |
The network part of the leaf operator may be specified here if it's provided by the upstream carrier. MNC is
an acronym for Mobile Network Code
|
|
Code example
Below you will find a code example for a callback for incoming SMS traffic.
Callback for incoming SMS C#
[Route("callback")] [ApiController] public class CallbackController : ControllerBase { private readonly SqlConnection Connection; public CallbackController() { Connection = new SqlConnection("Connection String"); Connection.Open(); } [HttpPost("")] public ActionResult HandleCallback(IncomingSms request) { using (SqlCommand cmd = new SqlCommand("INSERT INTO [Messaging].[SmsMessage] ([Sender],[Body]) VALUES (@sender, @body )", Connection)) { cmd.Parameters.AddWithValue("@sender", request.Sender); cmd.Parameters.AddWithValue("@body", request.Body); int result = cmd.ExecuteNonQuery(); } return Ok(); } } public class IncomingSms { public string Id { get; set; } public string BatchId { get; set; } public string Owner { get; set; } public string Sender { get; set; } public string Recipient { get; set; } public string Body { get; set; } public string Direction { get; set; } public int Segments { get; set; } public string Type { get; set; } public string DataEncoding { get; set; } public int Priority { get; set; } public List Statuses { get; set; } public DateTimeModified { get; set; } public string Mcc { get; set; } public string Mnc { get; set; } } public class Status { public DateTime Created { get; set; } public int Code { get; set; } public int Duration { get; set; } }