Creating a template is an important function of MMP Enterprise.
Please check Template > CreateTemplate API documentation.
Here is a simple function to call CreateTemplate API.
public static async Task<string> CreateTemplate() { try { // Create an email template using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
// Better you create a class for request and serialize it here... var request = "{\"accountId\": 17,\"name\": \"name_of_the_template\",\"subject\": \"Subject of the email\",\"body\": \"html> <head> </head> <body> Dear {{name}} {{surname}}, <a href=\"https:\/\/www.domain.com\/\">Please click the link.</a> <body> </html>\",\"poolId\": 8,\"mode\": \"HTML\",\"publicId\": \"JanNewsletter20200319",\"preHeader\":\"preheader_of_email\",\"fromid\": 15,\"replyId\": 12}";
// Target Url of at api... var uri = new Uri("[[BaseUrlOfApi]]/rest/template/email/create");
// Perform api call... var msg = new HttpRequestMessage(HttpMethod.Post, uri); msg.Content = new StringContent(request, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.SendAsync(msg, HttpCompletionOption.ResponseHeadersRead);
//Reading result & returning... var result = string.Empty; HttpContent content = response.Content; using (Task<string> completedTask = content.ReadAsStringAsync()) { result = completedTask.Result; completedTask.Dispose(); }
// If success, again you better create a class for api response and deserialize it here... return result; } catch (Exception ex) { System.Console.WriteLine(ex); return null; } }
accountId: This parameter must be given to you before you start developing.
publicId: Unique template id. If you don't give an id for the template, the system creates its own public id and puts this id in response. This parameter is used in SendBatch to define the template.
You can get the following ids by calling Configuration > GetSendParams function.
replyId: The id for reply address. This parameter must be created beforehand.
fromId: The id for from address. from nam/from address pair must be created beforehand.
poolId: The id for from pool. This parameter must be created beforehand.
The followings are optional parameters.
jsonData and csvData: This is the data to test the template through interface. You can ignore these parameters.
public static async Task<string> CreateTemplate() { try { using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
// 1 - Get Token... var tokenUrl = "[[BASE_API_URL]]/rest/login"; var tokenMsg = new HttpRequestMessage(HttpMethod.Post, tokenUrl); var userName = "[[USERNAME]]"; var password = "[[PASSWORD]]";
var result = string.Empty; HttpContent content = response.Content; using (Task<string> completedTask = content.ReadAsStringAsync()) { result = completedTask.Result; completedTask.Dispose(); }
dynamic deserializedResultObject = JsonConvert.DeserializeObject(result); var token = deserializedResultObject.token.Value;
// Add token to request... client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
// Better you create a class for request and serialize it here... var request = "{\"accountId\": 1,\"name\": \"your template name\",\"body\": \"Dear Our Customer {Name}. This is a test message for you.\",\"publicId\": \"6666\",\"poolId\": 1}";
// Target Url of at api... var uri = new Uri("[[BaseUrlOfApi]]/rest/template/email/create");
// Perform api call... var msg = new HttpRequestMessage(HttpMethod.Post, uri); msg.Content = new StringContent(request, Encoding.UTF8, "application/json"); response = await client.SendAsync(msg, HttpCompletionOption.ResponseHeadersRead);
//Reading result & returning... result = string.Empty; content = response.Content; using (Task<string> completedTask = content.ReadAsStringAsync()) { result = completedTask.Result; completedTask.Dispose(); }
// If success, again you better create a class for api response and deserialize it here... return result; } } catch (Exception ex) { System.Console.WriteLine(ex); return null; } }
accountId: This parameter must be given to you before you develop.
publicId: Unique template id. If you don't give it, the system creates its own public id. This parameter is used in SendBatch to define the template.
You can get the following ids by calling Configuration > GetSendParams function.
fromId: The id for from address. This from nam/from address pair must be created beforehand.
poolId: The id for from pool. This parameter must be created beforehand.
MMP Enterprise supports REST API's. Sending/Reporting Transactional Messages In MMP Enterprise, the type of the message (transactional vs batch) changes the way of sending and reporting. Transactional messages are kept in MMP Enterprise database and ...
SendBatch API is used to send batch(bulk) messages. The main inputs of a batch is Template + Data to be merged with this template. Please check SendBatch API documentation under Batch Send > SendBatch. Here is a simple function to call SendBatch API. ...
Configuring MMP Enterprise Configuring MMP Enterprise introduces several variables like From Address, Reply Addresses, LDAP Integration(optional), RabbitMQ Configuration, Send Pools, Users, Accounts, and lots of permissions. In the initial phase of ...
Advanced Personalization is a powerful feature in Dengage that lets you create content that adapts to each individual user. By leveraging data from your Master Contact or Master Device tables, you can make messages more relevant, engaging, and ...
SendTemplate API sends transactional messages (by merging the parameters and selected template to content) to recipients. Sending a template requires multiple steps: A template is created on Admin Panel or through REST API. There may be some ...