Skip to content

Sending active notifications

This service executes template notifications and sends to the users through WhatsApp

JSON Properties

  • hash: Hash of the company where the template is registered
  • templateName: The name of the template that will be executed.
  • templateNamespace: Namespace of the template that will be executed.
  • templateData: Contains the phone list and information about macros/variables for the template to be executed
    • DeliveryDate: (Optional) If you need to schedule the notification/template, then this field should be filled like YYYYMMDDHHMM
    • Reference: (Optional) You can use this field for any notes about this notification/template dispatch
    • PhoneList: Phone list separated by semicolons, e.g., “551199999999;551388888888”
    • Prop_Keys: Contains the list of macros/variables that will be replaced
      • PropName: Macro/Variable ID. It can be used as {{0}}, {{1}}, {{2}},…
        NOTE: The slot {{0}} is reserved for media files and the value should be an URL
      • PropValue: Value which will replace the macro/variable
    • Prop_Parms: Contains the list of parameters that will be added to the service execution
      • PropName: Name of the parameter that will be added
      • PropValue: Value of the parameter that will be added
  • ReturnMode: (Optional) Defines the type of return. If not informed, then DEFAULT will be applied
    • DEFAULT: Returns a phone list with the status of each dispatch
    • RESUME: Returns a JSON with data about the dispatch
      • RequestStatus: Notification dispatch status
        • CANCELED: All notifications cancelled
        • QUEUED: Notifications not sent yet
        • PROCESSED: All notifications have been sent
        • PROCESSING: The system is still sending notifications

Examples

Some examples on how to implement the dispatch of AnnA Notifications:

var httpClient = new HttpClient
{
BaseAddress = new Uri("YOUR_ANNA_URL")
};
var result = await httpClient.PostAsJsonAsync("REST/Credentials/GetToken", new
{
hash = "COMPANY_HASH",
user = "USER",
pass = "PASSWORD"
});
var tokenResponse = await result.Content.ReadFromJsonAsync<GetTokenResponse>();
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResponse?.Data.Token);
var notificationsResponse = await httpClient.PostAsJsonAsync("REST/Notifications/Send", new
{
hash = "COMPANY_HASH",
templateName = "TEMPLATE_NAME",
templateNamespace = "TEMPLATE_NAMESPACE",
templateData = new List<object>
{
new
{
PhoneList = "5511111111111;5522222222222",
Prop_Keys = new List<object>
{
new
{
PropName = "{{1}}",
PropValue = "Value 1"
}
},
Reference = "Test"
}
}
});
Console.WriteLine(await notificationsResponse.Content.ReadAsStringAsync());