Introduction
Consent records are automatically created based on the keywords received via incoming messages. E.g. Opt-In consent record will be automatically created when an incoming message is received with the “START” keyword. Source of such consent records is “Incoming SMS” (i.e. created via incoming messages).
Consent records can be managed (created/updated) by internal users (manually) and via automation as well. Source of such consent records is “Non-Handset” (i.e. created either manually or via automation, but not via incoming message).
SMS-Magic managed package has exposed a global class and an invocable global method which can be used to manage the consent records either via automation or programmatically.
Creating consent records programmatically
Technical details for utilizing global method from the managed package for creating consent records
Class Name | ConsentService |
Method Name | recordEventBasedConsent |
Parameter(s) | List<ConsentDataWrapper> |
Parameter details
The global method accepts the parameter in a pre-defined custom data type. Details of the parameters to be be passed to the global method
Parameter name | Data type | Is required | Description |
complianceStatus | String | Yes | Consent Status (Acceptable values: Opt-In, Opt-Out, Double Opt-In, Pending, Expired) (The acceptable values are case sensitive and should be in the exact format as mentioned.) |
phoneNumber | String | Yes | Phone Number (for which consent is to be created/updated) |
recordId | String | No | 18 character id of the record to which the phone number is associated with. If this record id is provided it is used to populate a look-up on the consent record. |
contentName | String | No | Value for this parameter is required when content type is one of the compliance parameters. |
senderId | String | No | Value for this parameter is required when sender id is one of the compliance parameter or consent is being created for non SMS channel (e.g. WhatsApp) |
sendConfirmation | Boolean | No | Default value for this parameter is ‘false’, meaning a confirmation will NOT be sent to the target phone number on creation of the consent record. If you wish to trigger the confirmation message, set the value for this parameter as ‘true’. |
commentMsg | String | No | If you want to store any comment related to the consent record you can pass it via this parameter. |
channelCode | String | No | Code the channel for which the consent record is being created. (e.g. 1 for SMS, 3 for WhatsApp, etc.). Default value for this parameter is 1. |
messageText | String | No | Custom message text to be sent after creation of the consent record. |
outgoingSenderId | String | No | Sender via which confirmation message should be sent. |
templateId | String | No | 18 character record id of the converse template record which should be referred for sending the confirmation message. |
Pseudo code (only for reference)
// instantia the custom datatype parameter for 'ConsentService' global method
List<smagicinteract.ConsentService.ConsentDataWrapper> consentDataList = new List<smagicinteract.ConsentService.ConsentDataWrapper>();
// create indivial record of the custom datatype parameter (this can be done in a loop when creating/updating multiple consent records)
smagicinteract.ConsentService.ConsentDataWrapper consentData = new smagicinteract.ConsentService.ConsentDataWrapper();
consentData.complianceStatus = 'Opt-In';
consentData.phoneNumber = '2034195847';// other parameters can also be set as per the requirement
consentDataList.add(consentData);
// call global method from 'ConsentService' and pass the 'consentDataList' parameter
smagicinteract.ConsentService.recordEventBasedConsent(consentDataList);