Skip to content

AnnA Active Notification (C#/.NET)

AnnA Active Notification is a resource that makes possible for you to send notifications through WhatsApp to a batch of phone numbers.

Using AnnaTemplate class

This class will provide you a simple way to send active notifications to your clients

Examples:

var template = new AnnaTemplate("YOUR_ANNA_ENVIRONMENT_BASE_URL");
template.CompanyHash = "YOURCOMPANYHASH";
template.EncryptionKey = "YOUR_TEMPLATES_ENCRYPTION_KEY";
template.DecryptionKey = "YOUR_TEMPLATES_DECRYPTION_KEY";
template.TemplateName = "TEMPLATE_NAME";
template.TemplateNamespace = "TEMPLATE_NAMESPACE";
template.Notifications = new List<AnnaNotification>(); // List of notification objects that contains PhoneList, PropKeys and PropParms

or

var template = new AnnaTemplate("YOUR_ANNA_ENVIRONMENT_BASE_URL", new AnnaTemplateConfig
{
CompanyHash = "YOURCOMPANYHASH",
EncryptionKey = "YOUR_TEMPLATES_ENCRYPTION_KEY",
DecryptionKey = "YOUR_TEMPLATES_DECRYPTION_KEY",
TemplateName = "TEMPLATE_NAME",
TemplateNamespace = "TEMPLATE_NAMESPACE",
Notifications = new List<AnnaNotification>() // List of notification objects that contains PhoneList, PropKeys and PropParms
});

Send notifications

What you will need:

  • Base URL of your AnnA environment
  • Company hash
  • Encryption and decryption key
  • Template name
  • Template namespace
  • List of phone numbers

Optionally you can set:

  • A media URL to send media files (IMAGE, VIDEO or DOCUMENT)
  • List with the values of variables from the template if your template has any
  • List with parameters for the template if your template has any
  • Delivery date when you want or need to schedule the notification
  • Reference to any notes about this notification
// Create notification
var notification = new AnnaNotification
{
PhoneList = new List<string> { "5511111111111", "5522222222222" }, // List of phonenumbers
MediaUrl = "https://example.com/image.png", // Set this property if you want to send media files (IMAGE, VIDEO or DOCUMENT)
PropKeys = new List<string> { "Variable 1" }, // List with the values of variables from the template
PropParms = new List<PropParm>
{
new PropParm { Alias = "parm1", Value = "value1" },
new PropParm { Alias = "parm2", Value = "value2" }
},
DeliveryDate = new DateTime(2023, 11, 02, 13, 20, 0), // Set this property if you want to schedule the notification
Reference = "Any description you want (max 100 characters)"
};
// Add notification to the list
var notificationsList = new List<AnnaNotification> { notification };
// Create the template, set the configurations and notifications list
// Example of AnnA environment base URL: https://learning.anna.center
var template = new AnnaTemplate("YOUR_ANNA_ENVIRONMENT_BASE_URL", new AnnaTemplateConfig
{
CompanyHash = "YOURCOMPANYHASH",
EncryptionKey = "YOUR_TEMPLATES_ENCRYPTION_KEY",
DecryptionKey = "YOUR_TEMPLATES_DECRYPTION_KEY",
TemplateName = "TEMPLATE_NAME",
TemplateNamespace = "TEMPLATE_NAMESPACE",
ReturnMode = TemplateReturnMode.DEFAULT, // Change to RESUME if you want information about the request instead of a phonelist when sending the notifications
Notifications = notificationsList
});
string response = template.SendNotifications(); // Send the notifications and returns a JSON

Get notification data

When sending notifications with ReturnMode as RESUME, the response will be a RequestID that you can use to get the notification data.

This service will return information about the number of notifications sent, processed and processing.

What you will need:

  • Base URL of your AnnA environment
  • Company hash
  • Encryption and decryption key
  • RequestID
// Create and configure AnnA Template
// Example of AnnA environment base URL: https://learning.anna.center
var template = new AnnaTemplate("YOUR_ANNA_ENVIRONMENT_BASE_URL", new AnnaTemplateConfig
{
CompanyHash = "YOURCOMPANYHASH",
EncryptionKey = "YOUR_TEMPLATES_ENCRYPTION_KEY",
DecryptionKey = "YOUR_TEMPLATES_DECRYPTION_KEY"
});
int requestId = 65; // RequestId from SendNotifications() reponse when ReturnMode is set to "RESUME"
string response = template.GetNotificationData(requestId); // JSON response with the notification data

GetNotificationData Response

The response will be a JSON with the following structure:

{
"RequestId": 1,
"RequestDate": "2023-06-05T16:00:00",
"RequestStatus": "PROCESSED",
"TotalNumberReceived": 4,
"TotalNumberValid": 4,
"TotalNumberSuccess": 4,
"TotalNumberError": 0,
"TotalNumberWaiting": 0,
"TotalNumberCanceled": 0,
"RequestResult": [
{
"RequestSeq": 1,
"RequestPhoneNumber":"111111111",
"RequestStatus":"sent",
"RequestMessage":"OK"
},
{
"RequestSeq": 1,
"RequestPhoneNumber": "222222222",
"RequestStatus": "sent",
"RequestMessage": "OK"
},
{
"RequestSeq": 2,
"RequestPhoneNumber": "333333333",
"RequestStatus": "sent",
"RequestMessage": "OK"
},
{
"RequestSeq": 2,
"RequestPhoneNumber": "444444444",
"RequestStatus":"sent",
"RequestMessage":"OK"
}
]
}
  • Possible values for base RequestStatus:
    • CANCELED
    • QUEUED
    • PROCESSED
    • PROCESSING
  • Possible values for RequestResult Status:
    • canceled
    • waiting
    • sent
    • delivered
    • failed