Getting Started with Cloud SMS
Requirements: Cloud SMS
Contents
- Introduction
- Selecting a Provider
- Authentication
- Common Operations
- Additional Functionality
- Supported Operations by Service Provider
Introduction
Cloud SMS provides an easy-to-use component for accessing various cloud SMS services, including:
- Twilio
- Sinch
- SMSGlobal
- SMS.to
- Vonage
- Clickatell
The SMS component is designed to provide a unified interface for basic functionality regardless of the service provider and may be used for any of the above providers. By supporting multiple providers with a single API code may be written once and used to support multiple services.
Capabilities include sending, scheduling, deleting, updating, listing, fetching, and more. Note that not all services support all operations. Tables are available at the end of this article as a quick reference, but consult the documentation of the individual service provider for the most up to date information on supported operations and if there are additional requirements or limitations to consider.
Selecting a Provider
To begin, first create an account and register with the desired service provider(s). Consult each provider's service documentation for instructions on this process.
Then, specify the provider by simply setting the ServiceProvider property. This tells the component to which service requests will be made.
Authentication
Once the account is created, the service provider will provide some form of credentials. Assign the provider account credentials to the corresponding AccountKey and AccountSecret properties. As a note, in some cases, the service provider does not provide or require an account secret.
Common Operations
Sending a Message
The Send method is used to send SMS messages without any delay.
The message details are specified by the MessageFrom, MessageRecipients, and MessageBody properties.
sms.MessageFrom = "+11234567890";
sms.MessageRecipients = "+10987654321";
sms.MessageBody = "This is an SMS message.";
string messageId = sms.Send();
Scheduling a Message
The ScheduleMessage method is used to delay SMS messages from being sent until the specified time.
The message details are specified by the MessageFrom, MessageRecipients, and MessageBody properties. The scheduled time to send is specified by the MessageDate property.
sms.MessageFrom = "+11234567890";
sms.MessageRecipients = "+10987654321";
sms.MessageBody = "This is an SMS message.";
sms.MessageDate = "2023-04-10T20:02:39Z";
string messageId = sms.ScheduleMessage();
Deleting a Message
The DeleteSentMessage and DeleteReceivedMessage methods are used to delete an SMS message that was sent or received, respectively.
In order to delete a message, the corresponding message ID must be provided to the method.
sms.MessageFrom = "+11234567890";
sms.MessageRecipients = "+10987654321";
sms.MessageBody = "This is an SMS message.";
string id = sms.Send();
// Wait for the message to send before deleting.
sms.DeleteSentMessage(id);
Updating a Message
The UpdateSentMessage method is used to update a sent SMS message with the values found it its corresponding Messages collection entry.
The specifics of what values can be updated and when the message is still available to be updated change significantly based on the service provider.
sms.MessageFrom = "+11234567890";
sms.MessageRecipients = "+10987654321";
sms.MessageBody = "This is an SMS message.";
string id = sms.Send();
// Wait for the message to send before updating with cleared body text.
sms.Messages[0].Body = "";
sms.UpdateSentMessage(id);
Listing Messages
The ListSentMessages and ListReceivedMessages methods list sent and received SMS messages, respectively, present on the authenticated account.
In order to refine which messages are listed, service-specific filters may be supplied.
string startTime = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
sms.MessageFrom = "+11234567890";
sms.MessageRecipients = "+10987654321";
sms.MessageBody = "This is an SMS message.";
sms.Send();
// Wait for the message to send before listing only the above message by supplying multiple filters.
sms.ListSentMessages("To=" + sms.MessageRecipients + "&DateSent>=" + startTime);
foreach (SMSMessage message in sms.Messages) {
if (message.From.Equals("+11234567890")) {
// . . .
}
}
Fetching a Message
The FetchSentMessage and FetchReceivedMessage methods can be used to fetch a specific SMS message that was sent or received, respectively.
In order to fetch a message, the corresponding message ID must be provided to the method.
sms.MessageFrom = "+11234567890";
sms.MessageRecipients = "+10987654321";
sms.MessageBody = "This is an SMS message.";
string id = sms.Send();
// Wait for the message to send before fetching.
sms.FetchSentMessage(id);
if (sms.Messages[0].MessageStatus.Equals("Delivered")) {
// . . .
}
Additional Functionality
The SMS component offers advanced functionality, including:
- The ability to detect and parse message status updates.
- The ability to accomplish service-specific tasks through the use of extra configuration settings.
- And more!
Supported Operations by Service Provider
* There is no distinction between calling send and receive variants of operations due to the fact that Twilio does not have separate endpoints for the two.
Twilio (SMS API)
Sending Scheduling Deleting Updating Listing Fetching |
Outgoing
Yes Yes Yes* Yes Yes* Yes* |
Incoming
- - Yes* - Yes* Yes* |
Sinch (SMS API)
Sending Scheduling Deleting Updating Listing Fetching |
Outgoing
Yes Yes Yes Yes Yes Yes |
Incoming
- - No - Yes Yes |
SMSGlobal (REST API)
Sending Scheduling Deleting Updating Listing Fetching |
Outgoing
Yes Yes Yes No Yes Yes |
Incoming
- - Yes - Yes Yes |
SMS.to (SMS API)
Sending Scheduling Deleting Updating Listing Fetching |
Outgoing
Yes Yes No No Yes Yes |
Incoming
- - No - Yes No |
Vonage (SMS API)
Sending Scheduling Deleting Updating Listing Fetching |
Outgoing
Yes No No No No No |
Incoming
- - No - No No |
Clickatell (One API)
Sending Scheduling Deleting Updating Listing Fetching |
Outgoing
Yes Yes No No No No |
Incoming
- - No - No No |
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.