-
Notifications
You must be signed in to change notification settings - Fork 2
/
addTemplate.js
45 lines (40 loc) · 1.07 KB
/
addTemplate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const SparkPost = require('sparkpost')
const fs = require('fs')
const TEMPLATE_HTML = fs.readFileSync(require.resolve('../template.html'), 'utf8')
/**
Update the following variables with your values
**/
const API_KEY = ''
const SENDING_DOMAIN = '' // e.g. aydrian.me
/**
-----------------------------------------------
**/
const client = new SparkPost(API_KEY)
const options = {
template: {
id: 'giphy-responder',
name: 'Giphy Responder',
description: 'Use with the giphy-responder application',
options: {
open_tracking: true,
click_tracking: true,
transactional: true
},
content: {
from: 'giphy-responder@' + SENDING_DOMAIN,
subject: 'Your {{ search }} gifs!',
html: TEMPLATE_HTML
}
}
}
if (API_KEY && SENDING_DOMAIN) {
client.templates.create(options, function (err, res) {
if (err) {
console.log(err)
} else {
console.log('Your Giphy Responder template has been successfully created.')
}
})
} else {
console.log('Please update the API_KEY and SENDING_DOMAIN variables and try again.')
}