I'm trying to work with handlebars, I've done exactly what tutorial says, my email doesn't seem to be formatting handlebars at all. What am I doing wrong. my sending default in mailchimp is handlebar too. I'm doing and using the tutorial example, provided in JSon, simply converted the code into javascript, however it doesn't seem to be working.
var mandrill = require('mandrill-api/mandrill');
var mandrill_client = new mandrill.Mandrill(MYAPIKEY);
var moment = require('moment-timezone');
var message = {
"subject": '',
"from_email": "myemail",
"from_name": "info",
"to": [{
"email": 'myemail',
"name": "Recipient Name",
"type": "to"
}],
"headers": {
"Reply-To": "message.reply@example.com"
},
"auto_text": true,
"inline_css": true,
"merge": true,
"merge_language": "handlebars",
"global_merge_vars": [
{
"name": "companyName",
"content": "Nesting Doll Emporium"
},
{
"name": "subject",
"content": "Thank you for your order."
}
],
"merge_vars": [
{
"rcpt": "myemail",
"vars": [
{
"name": "ordNumber",
"content": "478366238"
},
{
"name": "products",
"content": [
{
"img": "http://kbcdn.mandrill.com/nesting-penguin.png",
"qty": 2,
"sku": "PENG001",
"name": "Penguin",
"description": "Solid wood, hand-painted penguin nesting doll with 5 different sizes included. Limited Edition.",
"price": "12.99",
"ordPrice": "25.98"
},
{
"img": "http://kbcdn.mandrill.com/nesting-bear.png",
"qty": 3,
"sku": "BBEAR001",
"name": "Brown bear",
"description": "Solid wood, hand-painted brown bear nesting doll. Coordinates with our entire Bear collection. Includes 6 nested sizes.",
"price": "12.99",
"ordPrice": "38.97"
},
{
"img": "http://kbcdn.mandrill.com/nesting-tiger.png",
"qty": 1,
"sku": "TIGER030",
"name": "Tiger",
"description": "Orange striped tiger from our jungle collection.",
"price": "37.99",
"ordPrice": "37.99"
}
]
},
{
"name": "subtotal",
"content": "102.94"
},
{
"name": "shipping",
"content": "4.95"
},
{
"name": "ordTotal",
"content": "107.89"
},
{
"name": "customerName",
"content": [
{
"firstName": "Monty",
"lastName": "Python"
}
]
},
{
"name": "coupon",
"content": [
{
"code": "THANKS",
"description": "15% off"
}
]
},
{
"name": "billingAddress",
"content": [
{
"streetNum": "1234",
"address1": "BoulevArd Lane",
"city": "ATLANTA",
"state": "ga",
"zip": 30030
}
]
},
{
"name": "shippingAddress",
"content": [
{
"streetNum": 5678,
"address1": "BoulevArd Lane",
"city": "atlanta",
"state": "ga",
"zip": 30328
}
]
},
{
"name": "member",
"content": true
},
]
}],
};
var async = false;
var ip_pool = "Main Pool";
now = new Date();
minute = "" + now.getMinutes(); if (minute.length == 1) { minute = "0" + minute; }
second = "" + now.getSeconds(); if (second.length == 1) { second = "0" + second; }
var send_at = moment().format('YYYY-MM-DD HH:'+minute+':'+second);
var template_content = [{
"name": 'handle_bar_test',
"content": "example content"
}];
const payload ={
'template_name':'handle_bar_test',
'template_content': [],
'message':message,
'async':async,
'ip_pool':ip_pool,
'send_at':send_at
}
mandrill_client.messages.sendTemplate(payload, function(result) {
console.log(result);
},
function(e) {
console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message);
});