Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Notify integration guidance #574

Merged
merged 9 commits into from
Oct 29, 2018
Merged

Add Notify integration guidance #574

merged 9 commits into from
Oct 29, 2018

Conversation

quis
Copy link
Member

@quis quis commented Aug 2, 2018

@@ -0,0 +1,48 @@
To set it locally, run this command in your Terminal, in the root
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like there's some context missing here – I don't know what Notify is, and whether I want to (or need to) use it. The guidance is talking about 'setting it' but I have no idea what 'it' is.

```shell
echo NOTIFYAPIKEY=xxxxxxx >> .env
````
(where xxxxxxx is a key you’ve created in Notify). This creates a file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In most cases, .env should already exist thanks to

// Create template .env file if it doesn't exist
const envExists = fs.existsSync(path.join(__dirname, '/.env'))
if (!envExists) {
fs.createReadStream(path.join(__dirname, '/lib/template.env'))
.pipe(fs.createWriteStream(path.join(__dirname, '/.env')))
}
}

If I had already customised that file and didn't know what that command did, I'd be nervous that it'd wipe out my existing env configuration.

docs/documentation/using-notify.md Show resolved Hide resolved
(where xxxxxxx is a key you’ve created in Notify). This creates a file
named `.env` which contains your API key.

To set it on Heroku, go to the settings page on your app, click
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it clear that users will need to do this for Heroku (if they're using Heroku) as well as locally, because their .env file won't (shouldn't) be committed? At the minute it could be interpreted as an either/or thing.

This code goes at the bottom of routes.js:

```javascript
router.post('/page-with-email-or-phone-input', function (req, res) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call out that this needs to be the same URL that the form POSTs to?

@quis
Copy link
Member Author

quis commented Aug 9, 2018

Thanks for the comments @36degrees. I will tidy this up when I have a bit more time…

@quis
Copy link
Member Author

quis commented Sep 28, 2018

I’ve rewritten the instructions to add a lot more context. The previous instructions were a very bare-bones draft which assumed a lot of knowledge.

Hopefully this is enough so that someone who is confident using the prototype kit can integrate their prototype with Notify.


You can use GOV.UK Notify to send text messages or emails when users
interact with your prototype. For example you could send users a
confirmation email sent at the end of a journey.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repetition of 'sent'/'send'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


To save the key on your computer, run this command in your Terminal, in
the root folder of your prototype (where xxxxxxx is a key you’ve copied
from Notify):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be less daunting to just tell people to add this line to end of .env - and they'll use whatever tool is familiar to them. The only downside is there's a possibility .env doesn't exist (before running for the first time), though if so people just need to run the kit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

### Keeping your key safe

It’s really important that you keep your key secret. If you put it in
the `.env` file it’s safe – that file isn’t published on Github. If you
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github > GitHub

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notify = new NotifyClient(process.env.NOTIFYAPIKEY);
```

`process.env.NOTIFYAPIKEY` is a special kind of variable that Node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure users need to know this? Might be simpler to leave it out

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a page with a form to collect the user’s email address. For
example:
```
{% from "input/macro.njk" import govukInput %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we replace this with the HTML for now? We're not really pushing the macros as the main approach yet, as the error handling is really bad and we don't cover them in the training yet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Save this page as `email-address-page.html`.

Then add this code at the bottom of routes.js:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to be above module.exports = router

I wonder if there's a way to provide all this code as examples, though I know we can't distribute a Notify key. Hmm

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joelanman
Copy link
Contributor

This is great, thanks Chris! It would be great for one of us to do some guerilla testing and see if someone can follow these instructions easily and send an email.

Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this and it works well – though the example form doesn't extend the layout so if you blindly copy the instructions you get an unstyled form without the header, footer, etc.

The previous instructions were a very bare-bones draft which assumed a
lot of context.

This commit attempts to rewrite them for someone without knowledge of
what Notify is, or how an API works.

Hopefully this is enough so that someone who is confident using the
prototype kit can integrate their prototype with Notify.
@quis quis changed the title Add first draft of Notify integration guidance Add Notify integration guidance Oct 29, 2018
@kr8n3r kr8n3r merged commit 77a1205 into alphagov:master Oct 29, 2018
@kr8n3r kr8n3r mentioned this pull request Nov 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants