From 344c4306712c02d4e729f6c7fef3aaa0486f700b Mon Sep 17 00:00:00 2001 From: Ram <80714392+ramsharma-prog@users.noreply.github.com> Date: Thu, 21 Dec 2023 13:08:02 +0000 Subject: [PATCH] updated readme: (#181) --- README.md | 64 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a581ffbc..c007384e 100644 --- a/README.md +++ b/README.md @@ -45,24 +45,64 @@ Then run: pip-compile requirements-dev.in ## How to use -1. Set-up an API KEY that requires to connect with the govuk-notify-service +Refer to the steps as required +### Create a new notification api key +api key is required for a service to communicate with GOV.UK Notify service - Click on the link & follow the instructions to set-up an API KEY. - https://docs.notifications.service.gov.uk/python.html#api-keys +- Refer to the link [here](https://www.notifications.service.gov.uk/services/505ca282-bfde-4fae-8d8a-ff09906a23fa/api/keys) to create a new api key as required - Set it as an environment variable e.g. +### Add api key to the notification service +Production api key **(DO NOT USE IT LOCALLY)** + - The production api key must always be kept secure hence it is added to the Github secrets. + +Test api key **(for local use)** +- The test api key can be temporarily added to the config file or export it to the local environment for testing purposes only. Make sure to remove the test api key from config file before committing any changes. + Set it as an environment variable e.g. ``` // pragma: allowlist secret export GOV_NOTIFY_API_KEY="api-key-value ``` - Note: For unit (integration) testing, you also need to set this in `pytest.ini` -2. Enter the virtual environment as described above, then: +### Create a new template +Template is required for a service to communicate with GOV.UK Notify service. + +Typically, a template contains information in a text format, with attributes enclosed in double parentheses, such as ((attribute name)). These attribute will then be required for a service to make a call to that unique template. + +- Refer to the link [here](https://www.notifications.service.gov.uk/services/505ca282-bfde-4fae-8d8a-ff09906a23fa/templates) to create a new template + +### Add new template in the notification service +Once a template is created using the GOV.UK Notify service, it generates a unique template ID. This ID can then be directly incorporated into the configuration file. Then this template ID can be used across the service and to make a call to the GOV.UK Notify service. + +- For example APPLICATION_RECORD_TEMPLATE_ID is added [here](https://github.com/communitiesuk/funding-service-design-notification/blob/17d27ed6b7bba556214a01d1196d828b583ab40d/config/envs/default.py#L30) + +### Format contents for readability (optional) +When an applicant submits their application, we send a file containing the application's questions and answers back to the applicant and at the end of the assessment, once the QA section is completed, we make files available for download containing the application's questions and answers. There is a functionality within the utils-service [here](https://github.com/communitiesuk/funding-service-design-utils/blob/af29613c764e83b1690d4cb25ca21341113b20af/fsd_utils/mapping/application/qa_mapping.py#L13), which is employed by both the notification service and assessment frontend to facilitate this task. + +To ensure that questions and answers are mapped correctly and formatted for better readability, especially when creating a new fund, it's essential to review the questions & answers. The text file can be located in [GOV.UK Notify service](https://www.notifications.service.gov.uk/services/505ca282-bfde-4fae-8d8a-ff09906a23fa/api) after the application submission. + +The dev team recently carried out some work to organise and arrange the questions and answers, making it easier for all services to use them. The notification service may not require the mapping and formatting, so instead, the formatting can happen in the application-store. Then, the notification service can simply act as a dumb service to send messages to users without needing to do extra organising. + +### Post contents to GOV.UK Notify service +Instantiate a notifications_client object using the notification api key. Next, utilise the preferred service, like send_email_notification, to access the email service. + +For this service (notifications_client.send_email_notification), you'll need to some required attributes such as email_address, template_id, email_reply_to_id etc. + +Based on the attributes set on the template during its creation, ensure that all attribute values are added to personalisation. + +- To connect with GOV.UK Notify service and post contents, refer to this [example](https://github.com/communitiesuk/funding-service-design-notification/blob/17d27ed6b7bba556214a01d1196d828b583ab40d/app/notification/model/notifier.py#L25). + +**For more information, refer to the documentation** [here](https://www.notifications.service.gov.uk/using-notify). + +### Configuring new fund on Notification service +- Refer to the documentation [here](https://dluhcdigital.atlassian.net/wiki/spaces/FS/pages/45973632/Configuring+Notification+service+for+New+Funds+and+Templates) + + +### To run the service locally `flask run` - Note: This service is an internal service so it doesn't have the frontend. +Note: This service is an internal service so it doesn't have the frontend. # Run with Gunicorn @@ -76,10 +116,6 @@ Then run gunicorn using the following command: gunicorn wsgi:app -c run/gunicorn/local.py -## How to post data for notification service. - -Go to relevant service. See example -path: app/notification/magic_link/README.md for ### Build with Paketo @@ -114,6 +150,12 @@ CONTAINER ID IMAGE COMMAND CREATED 42633142c619 paketo-demofsd-app "/cnb/process/web" 8 seconds ago Up 7 seconds 0.0.0.0:8080->8080/tcp peaceful_knuth ``` +# Pipelines + +Place brief descriptions of Pipelines here + +- Deploy to Gov PaaS - This is a simple pipeline to demonstrate capabilities. Builds, tests and deploys a simple python application to the PaaS for evaluation in Dev and Test Only. + # Testing This repo comes with a `.pre-commit-config.yaml`, if you wish to use this do