This repository is designed to manage email templates and test data for the capture service. It is built to make it simple and accessible for anyone, including new developers, to create, edit, validate, and preview email templates. You can edit the HTML files using any text editor you prefer.
The Capture service fetches email templates in real time. However, due to a caching mechanism, it may take up to one hour for template updates to take effect.
To create customized email templates for Capture-powered services, please contact the Numbers Team at hi@numbersprotocol.io to obtain an API Key and reserve a unique service name. You can also optionally customize the service logo and service email used in the templates.
-
Contains all email templates, organized by service, template name, and language.
-
Path structure:
./templates/<service-name>/<template-name>/<language>.html
-
Defaults:
service-name:capturelanguage:en-us
-
Fallback Behavior:
- If a specific language HTML file does not exist for a service and the user has set that language in their preferences, the system will first fall back to
en-usfor that service. - If the
en-usfile also does not exist for the service, the system will fall back to thecaptureservice's template for the same template name.
- If a specific language HTML file does not exist for a service and the user has set that language in their preferences, the system will first fall back to
Example:
./templates/capture/password_reset/en-us.html-
Contains test data for templates.
-
Path structure:
./test/<template-name>/data.json
-
Test data is shared across all services and languages for a given template.
Example:
./test/password_reset/data.jsonSample content for data.json:
{
"action_url": "https://api.numbersprotocol.io/account/password_reset/0/0",
"service_info": {
"display_name": "The Capture Team",
"service_logo": "https://static-cdn.numbersprotocol.io/Capture+GradBlue+Icon+Wordmark.png"
}
}-
Create the Directory Structure:
Run the following command to create a new directory for the service and copy the existing templates from the
captureservice:mkdir -p ./templates/<new-service-name> && cp -r ./templates/capture/* ./templates/<new-service-name>/
Replace
<new-service-name>with the name of your new service. -
Edit the Templates: Navigate to the new service's directory and update the templates as needed. Use any editor you prefer. Example:
nano ./templates/<new-service-name>/password_reset/en-us.html
-
Add or Modify Test Data: Test data is shared across services. If necessary, update the corresponding test data in
./test/<template-name>/data.json. Example:nano ./test/password_reset/data.json
-
Validate Your HTML: Run
npm run testto ensure your templates are valid.
- Locate the template in
./templates/<service-name>/<template-name>/<language>.html. - Make your changes using your preferred editor.
- Update the corresponding test data in
./test/<template-name>/data.jsonif needed. - Run
npm run testto validate the changes. - Preview your changes using
npm run buildandnpm run dev.
Validates all HTML templates using the html-validate tool to ensure they meet the required standards.
Generates a preview webpage (index.html) for all templates.
Starts a local development server at http://localhost:3000 to preview email content in a browser.
- Run
npm run buildto generate the preview webpage. - Start the development server using
npm run dev. - Open
http://localhost:3000in your browser. - Select a template from the sidebar to view its content on the right-hand side.