Communication module
Implements integration with Twilio service.
Configuration
twilio.sendgrid.api.debug-mode- boolean value. Settrueif you want Twilio to perform validation of email without sending it further otherwise - usefalse.twilio.sendgrid.api.key- string value. It's an api key provided by Twilio Sendgrid. You can create it here.
Sending emails
You can use fr.lifeconnect.adb.communication.service.EmailService::send method for sending emails. Before sending make sure that email that is going to be used as from email is verified. You can verify specific email of the whole domain here. Use can define email content by using either templates or raw html. To manage templates, use TemplateService.
Email state events webhook
Currently, webhook is managed by adb-persons service and configured in fr.lifeconnect.adb.person.config.EmailStateEventWebhookConfig configuration. It receives events emitted by Twilio Sendgrid (you can configure it here). You can read about event types here. All state events are stored in email_state_events collection, then trigger with queue can be created so other services could source incoming events.
Email templates
Templates can be managed from fr.lifeconnect.adb.communication.service.TemplateService service as well as from Twilio Sendgrid dashboard. Templates have versioning system, so every time we edit a template - new version is created. In templates dynamic variables can be used like that: {{dynamic_variable}}, then you just need to pass value of dynamic_variable in this config field fr.lifeconnect.adb.communication.model.SendEmailConfig.templateData.
Email scheduling
Emails can be scheduled with fr.lifeconnect.adb.communication.service.ScheduleService. By calling ScheduleService::scheduleEvent you can create Schedule for EventBridge. When time comes it will send the event to proper queue. So don't forget to create queue and listener for specific event type. In the listener handler you can put logic responsible for pdf generation and email sending, after sending the email don't forget to delete schedule with ScheduleService::deleteScheduledEvent.