Voice Elements SMS

From VESupport

Jump to: navigation, search

The development team is excited to announce our SMS service platform. We have two implementations to allow you complete control of how you can use SMS in your organization.

  • SMS using your VoiceElements Client
  • SMS via REST API's


SMS From Within Your VoiceElements Application

Sending and receiving SMS from within VoiceElements is a snap. It requires version 8.6.3 of the VoiceElements Client. This is now available on NUGET:

https://www.nuget.org/packages/InventiveLabs.VoiceElementsClient/

Before you can use SMS, you must set the encryption keys. These keys are unique to your account and you can get the keys for your SMS enabled number(s) from our portal:

https://customer.voiceelements.com/

Setting the keys in code is done at startup:

                   s_telephonyServer.SmsMyPrivateKeyXml = myCustomerKeyPairXml;
                   s_telephonyServer.SmsBorderElementsPublicKeyXml = myBorderKeyPairXml;

You should also subscribe to the SMS events to receive SMS messages and delivery reports:

                   s_telephonyServer.SmsMessage += TelephonyServer_SmsMessage;
                   s_telephonyServer.SmsDeliveryReport += TelephonyServer_SmsDeliveryReport;

After these are set, you can easily send an SMS message as in this example:

       public static void SendSms(string number, string smsText)
       {
           try
           {
               Guid messageGuid;
               string[] headers;
               string[] sdp;

               var sipStatusCode = s_telephonyServer.SmsSendMessage(smsText, number, fromNumber, null, out messageGuid, out headers, out sdp);
               Log.Write("SMS Result: {0}", sipStatusCode);
           }
           catch (Exception ex)
           {
               Log.WriteException(ex, "SendSms()");
           }

       }


And then handle imcoming SMS messages upon arrival:

       private static void TelephonyServer_SmsMessage(object sender, SmsMessageEventArgs e)
       {
           Log.Write($"Received SMS (From: {e.SmsFrom}, To: {e.SmsTo}): {e.SmsMessage}");
       }

The system will also give you delivery reports for sent SMS messages:

       private static void TelephonyServer_SmsDeliveryReport(object sender, SmsDeliveryReportEventArgs e)
       {
           if (string.IsNullOrWhiteSpace(e.DeliveryDescription) && e.DeliveryState.ToLower() == "waiting")
           {
               Log.Write($"Received SMS Delivery Report (From: {e.SmsFrom}, To: {e.SmsTo}): Message delivery is pending...");
           }
           else
           {
               Log.Write($"Received SMS Delivery Report (From: {e.SmsFrom}, To: {e.SmsTo}): {e.DeliveryDescription}");
           }
       }

You can also request that any undelivered SMS messages be sent to you. These would be messages that may have arrived while your application was offline.

               try
               {
                   string[] headers;
                   string[] sdp;
  
                   var result = s_telephonyServer.SmsRequestUndeliveredMessages(out headers, out sdp);
                   Log.Write($"Requesting undelivered SMS messages.  Result: {result}");
               }
               catch { }

SMS Via REST APIs

Using our REST APIs for SMS is done by first getting a security key from our portal:

https://customer.voiceelements.com/

Messages are then sent to our servers by way of REST calls to our server. For example to send a message:

https://ivlrest.voiceelements.com/v1/SendSMS passing in JSON that takes this form:

{
"toNumber": "3035551212", 
"fromNumber": "6025551212",
"text": "Your text here",
"customerTag": ""
}

For complete documentation, please visit this link:

http://download.voiceelements.com/SMS.REST.API.Reference.Documentation.pdf

For receiving SMS messages, we will POST back JSON to your server in a similar fashion.

This is also documented in the above referenced link.

Personal tools