Background:
Currently, Sunbird email service is used to send the notification to the user on different actions in review workflow. Sunbird uses same default email templates for all workflow actions such as publish, request changes.
Problem statement:
Email template configuration at action/channel level for review workflow in content service should be provided
Proposed Solution:
Default Templates
Sunbird comes with default templates for actions in content review workflow. Below are the default templates present in Sunbird.
- Send for review
- Request for changes
- Publish
Default templates will be stored in sunbird middleware(learner service) and configuration for the template will be stored as form config. Default template can also be configured at the installation time using Form API's.
Below is the sample template configuration for different content review workflows stored in form service.
Publish
{
"request": {
"type": "notification",
"action": "publish",
"subType": "email",
"data": {
"templateName": "publishedTemplate",
"action": "publish",
"fields": [{
"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"
}]
}
}
}
Request Changes
{
"request": {
"type": "notification",
"action": "requestChanges",
"subType": "email",
"data": {
"templateName": "requestChangesTemplate",
"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> Content Title: </b>{{Content title}}<br> <b>Content Link: </b>{{Content link}}<br>",
"subject": "Congratulations, your content is live!",
"logo": "https://dev.open-sunbird.org/assets/images/sunbird_logo.png"
}
}
}
Send for Review
{
"request": {
"type": "notification",
"action": "sendforReview",
"subType": "email",
"data": {
"templateName": "sendforReviewTemplate",
"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> Content Title: </b>{{Content title}}<br> <b>Content Link: </b>{{Content link}}<br>",
"subject": "Congratulations, your content is live!",
"logo": "https://dev.open-sunbird.org/assets/images/sunbird_logo.png"
}
}
}
In the above request,
- type: is the type of form.
- action: workFlow action.
- subType: type of notification.
- templateName: name used to store in Cassandra DB.
- body: Body of the Email.
- subject: subject of Email.
- logo: log used in Email. If not sent default will be used.
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 custom email template channel/tenant specific. If customized templates are not present, the default template will be used to send email for different actions in review workflows.
If any tenants want to configure their own email template, they can do so by adding new email template configurations in Form API and manually inserting the new template in Casandra DB of Sunbird middleware service.
Instruction to create custom templates
- Templates name configured in Form API should be in "slug_workflowAction" format.
- Templates name used to store in Cassandra DB should be same as configured in Form API
- rootOrgId should be added in form API request along with other fields.
- Placeholders should be there in their respective fields.
- If the custom template is configured in form service, then custom template with the same name should also be added in Learner service(sunbird middleware). If not added Learner service will throw an error.
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": "sendforReviewTemplate",
"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> Content Title: </b>{{Content title}}<br> <b>Content Link: </b>{{Content link}}<br>",
"subject": "Congratulations, your content is live!",
"logo": "https://dev.open-sunbird.org/assets/images/sunbird_logo.png"
}
}
}
Limitation:
- Only predefined placeHolder can be dynamically replaced with content data while sending mail