## Background:
Currently, Sunbird email service is used to send notification to user on different action in review workflow. Sunbird uses same default email templates for all workflow actions such as publish, request changes.
##Problem statement:
Making email template configurable at action/channel level for review workflow in content service.
##Proposed Solution:
###Default Templates
Sunbird comes with default templates for major actions in review workflow. Below are the default templates present in sunbird.
1. Send for review
2. Request for changes
2. Publish
Default templets will be stored in sunbird middleware and configuration for template will be stored in Form Service. Default template can also be configured at the installation time using Form service API's.
Please find sample template configuration for publish content stored in form service.
{
"request": {
"type": "notification",
"action": "publish",
"subType": "email",
"data": {
"templateName": "publishedTemplate",
"body": "Congratulations! The content that you had submitted
has been accepted for publication. It will be available for usage shortly.<br><br>
<b>Content Type: </b>{{Content type}}<br>
<b>Title: </b>{{Content title}}<br>
<b>Link: </b>{{Content link}}<br>",
"subject": "Congratulations, your content is live!
Content Type: {{Content type}}, Title: {{Content title}}",
"logo": "https://dev.open-sunbird.org/assets/images/sunbird_logo.png"
}
}
}
Below placeholders are used to dynamically change the content information. So, it is recommended to keep this respective fields:
* {{Content type}}
* {{Content title}}
* {{Content link}}
###Custom templates:
We can also create customize email template channel/tenant specific. If customized templates are not present, default template will be used to send email for different actions in review workflows.
If any tenants wants to configure their own email template, they can do so by adding new email template configurations in Form API and subsequently inserting new template in Sunbird middleware service.
#####Instruction to create custom templates
* Templates name configured in Form API should be in "slug_workflowAction" format.
* rootOrgId should be added in form API request.
* Placeholders should be there in their respective fields.
* If custom template is configured in form service, then custom template with same name should also be added in sunbird middleware
For example, If slug is "sunbird" and action is send for review, template name should be "sunbird_sendforReviewTemplate". Sample custom template configuration.
{
"request": {
"type": "notification",
"action": "sendForReview",
"subType": "email",
"rootOrgId": "0123166367624478721",
"data": {
"templateName": "sunbird_sendforReviewTemplate",
"body": "A content has been submitted for review.<br><br>
<b>Content Type: </b>{{Content type}}<br>
<b>Title: </b>{{Content title}}<br>
<b>Creator: </b>{{Creator name}}<br>"
<b>Link: </b>{{Content link}}<br>",
"subject": "Content has been submitted for review
Content Type: {{Content type}}, Title: {{Content title}}",
"logo": "https://dev.open-sunbird.org/assets/images/sunbird_logo.png"
}
}