Last active
August 1, 2018 14:41
-
-
Save quis/1136d255a5cdc47f4b72bc5bf234cf97 to your computer and use it in GitHub Desktop.
How to integrate the prototype kit with GOV.UK Notify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add this code to the top of routes.js | |
// process.env.NOTIFYAPIKEY is a special kind of variable that Node | |
// pulls from the environment your prototype is running in | |
// | |
// To set it locally, run this command in your Terminal, in the root | |
// folder of your prototype: | |
// echo NOTIFYAPIKEY=xxxxxxx >> .env | |
// (where xxxxxxx is a key you’ve created in Notify) | |
// | |
// To set it on Heroku, go to the settings page on your app, click | |
// ‘reveal config vars’ and enter NOTIFYAPIKEY and the value of the key | |
// in the two boxes. | |
var NotifyClient = require('notifications-node-client').NotifyClient, | |
notify = new NotifyClient(process.env.NOTIFYAPIKEY), | |
// --------------------------------------------------------------------- | |
// Add these bits at the bottom of routes.js | |
// The URL here should be the same as the form where someone enters | |
// their email address/phone number | |
// | |
// That page needs a textbox called 'email', to match req.body.email | |
// below, eg <input type='text' name='email' /> | |
// | |
router.post('/page-with-contact-details-form', function (req, res) { | |
notify.sendEmail( | |
// this long string is the template ID, get it from Notify | |
'24a8b897-2de9-4a9f-a2db-b6ef682f799a', | |
req.body.email, | |
{} | |
); | |
// This URL should be the page you want to send people to after the | |
// email message has been sent | |
res.redirect('/journey/dvla-change-address/' + req.params.id + '/confirm-email'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment