-
Notifications
You must be signed in to change notification settings - Fork 1
Messaging
Sending a message is easy, there are several ways we allow you to send messages.
MessagesActions.SendMessage("Hello John, you have an appointment at 3PM today.", "7195552656");
MessagesActions.SendMessage("Flash sale today! All products 10% off!", "7195559696", "7195554752");
NOTE YOU MUST USE DateTime.UtcNow
NOT DateTime.Now
MessagesActions.SendMessage("Hello Mary, is your refigrator running?", DateTime.UtcNow.AddMinutes(10), "7195554752");
NOTE YOU MUST USE DateTime.UtcNow
NOT DateTime.Now
MessagesActions.SendMessage("Office meeting at 3:30 Friday. Get ready for layoffs!", DateTime.UtcNow.AddMinutes(10), "7195554752", "17195553382");
Sometimes we don't want an exception to be thrown if the message does not go through. If you want to disable exceptions for sending a single message you can set the DisableExceptions
property to false
in the message actions class
MessagesActions.DisableExceptions = true;
We strongly suggest that if you do this, you also verify the message went through by checking the .Accepted
property of the SendMessageStatus
class or by checking the .error
property.
ClickATel.Models.Message ViaMsgCls = new ClickATel.Models.Message
{
To = new List<string> { "9705552141", "7195552297", "7195556630", "7195553021" },
DeliverAt = DateTime.UtcNow.AddMinutes(5),
Message_Text = "You won a Free iPad! Send your SSN now!",
From = "19702817674"
};
MessagesActions.SendMessage(ViaMsgCls);
By default the SendMessage()
function will either return SendMessageStatus
for single messages or SendMessagesStatus
for multiple messages.
If you are sending a single message you can simply add .Accepted
to see if the message was accepted
bool sent = MessagesActions.SendMessage("Hello John, you have an appointment at 3PM today.", "7195552656").Accepted;
or you can assign it to a variable and see if it was accepted here
SendMessagesStatus msgs = MessagesActions.SendMessage("Hello, sale starts today!", "7195559696", "7195554752");
foreach(SendMessageStatus m in msgs)
{
Console.WriteLine("{0,-16} Accepted: {1}", m.toNumber , m.Accepted);
}
If the message was not accepted you can check to see why it was rejected by retrieving the .errorDescription
property
if (msg.Accepted)
Console.WriteLine("Message Accepted! {0}", msg.MessageID);
else
Console.WriteLine("Message Was not accepted {0}", msg.errorDescription);
By default the SendMessage()
function will either return SendMessageStatus
for single messages or SendMessagesStatus
for multiple messages.
If you are sending a single message you can simply add .MessageID
to get the MessageID from click-a-tell
string sent_ID = MessagesActions.SendMessage("Hello John, you have an appointment at 3PM today.", "7195552656").MessageID;
or you can assign it to a variable and see if it was accepted here
SendMessagesStatus msgs = MessagesActions.SendMessage("Bear seen in your backyard!", "7195559696", "7195554752");
foreach(SendMessageStatus m in msgs)
{
Console.WriteLine("{0,-16} Message ID: {1}", m.toNumber , m.MessageID);
}