Notificaciones Activas de AnnA
AnnA Active Notification es un recurso que permite enviar notificaciones a través de WhatsApp a un grupo de números de teléfono.
Utilizando la clase AnnaTemplate
Esta clase te proporcionará una forma sencilla de enviar notificaciones activas a tus clientes.
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
o
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 });
Enviando notificaciones
Lo que necesitarás:
- URL base de tu entorno AnnA
- Hash de la empresa
- Clave de cifrado y descifrado
- Nombre del template
- Namespace del template
- Lista de números de teléfono
Opcionalmente, puedes configurar:
- Una URL de medios para enviar archivos de imagen (IMAGEN, VIDEO o DOCUMENTO)
- Lista con los valores de las variables del template, si tu template tiene alguno
- Lista con parámetros para el template, si tu template tiene alguno
- Fecha de entrega para programar la notificación, si es necesario o deseado
- Referencia a cualquier nota sobre esta notificación
// 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
Cómo obtener los datos de la notificación
Al enviar notificaciones con ReturnMode como RESUME, la respuesta será un RequestID que puedes usar para obtener los datos de la notificación.
Este servicio proporcionará información sobre la cantidad de notificaciones enviadas, procesadas y en proceso.
Lo que necesitarás
- URL base de tu entorno AnnA
- Hash de la empresa
- Clave de cifrado y descifrado
- 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 - Respuesta
La respuesta del método GetNotificationData es una cadena JSON con la siguiente estructura:
{ "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", "RequestSentDatetime": "2024-08-05T16:00:00", "RequestDeliveryDatetime": "2024-08-05T16:00:00", "RequestReadDatetime": "2024-08-05T16:00:00", "RequestHasButton": true, "RequestUserAnswered": true, "RequestUserAnswer": "Sim", "SentKeys": [ { "Description": "NOME", "Value": "Giuliano" } ], "SentParms": [ { "Cod": "CPF", "Value": "11111111111" }, { "Cod": "RG", "Value": "11111111-1" }, ] }, { "RequestSeq": 1, "RequestPhoneNumber": "222222222", "RequestStatus": "sent", "RequestMessage": "OK", "RequestSentDatetime": "2024-08-05T16:00:00", "RequestDeliveryDatetime": "2024-08-05T16:00:00", "RequestReadDatetime": "2024-08-05T16:00:00", "RequestHasButton": true, "RequestUserAnswered": true, "RequestUserAnswer": "Sim", "SentKeys": [ { "Description": "NOME", "Value": "Giuliano" } ], "SentParms": [ { "Cod": "CPF", "Value": "11111111111" }, { "Cod": "RG", "Value": "11111111-1" }, ] }, { "RequestSeq": 2, "RequestPhoneNumber": "333333333", "RequestStatus": "sent", "RequestMessage": "OK", "RequestSentDatetime": "2024-08-05T16:00:00", "RequestDeliveryDatetime": "2024-08-05T16:00:00", "RequestReadDatetime": "2024-08-05T16:00:00", "RequestHasButton": true, "RequestUserAnswered": true, "RequestUserAnswer": "Sim", "SentKeys": [ { "Description": "NOME", "Value": "Giuliano" } ], "SentParms": [ { "Cod": "CPF", "Value": "11111111111" }, { "Cod": "RG", "Value": "11111111-1" }, ] }, { "RequestSeq": 2, "RequestPhoneNumber": "444444444", "RequestStatus":"sent", "RequestMessage":"OK", "RequestSentDatetime": "2024-08-05T16:00:00", "RequestDeliveryDatetime": "2024-08-05T16:00:00", "RequestReadDatetime": "2024-08-05T16:00:00", "RequestHasButton": true, "RequestUserAnswered": true, "RequestUserAnswer": "Sim", "SentKeys": [ { "Description": "NOME", "Value": "Giuliano" } ], "SentParms": [ { "Cod": "CPF", "Value": "11111111111" }, { "Cod": "RG", "Value": "11111111-1" }, ] } ] }
- Valores para el status de RequestStatus base:
- CANCELED
- QUEUED
- PROCESSED
- PROCESSING
- Valores para el status de RequestResult:
- canceled
- waiting
- sent
- delivered
- failed