# Messaging Context
Messaging bounded context is part of the communications subdomain.
Note: None of these are implemented as of yet. We have done a few spikes to understand how we can achieve a certain things, and they're documented here.
The requirement for our messaging system are the following:
- Message should be able to be sent to various channels such as SMS, WhatsApp, and Chat
- Message should be able to be sent via emails. When a building contact receive an email, the original seeker's email address must be replaced by a proxy email address.
# Sequence: Starting a conversation
Before messages can be sent, a Twilio conversation must be created first. A conversation should be created on the instance where a seeker is about to send a message to a building contact.
Details:
- We must be able to distinguish the role of the participants, whether they are
a seeker or a building contact, because we will have to handle their messages
differently. To achieve this, participants must be created with
attributes
, where the role information can be stored.
# Sequence: Sending message from conversation channels
In this diagram, the Sender
can send message from any of the supported
channels by Twilio. Even though this sequence diagram works for both seekers and
building contacts, there is a slight difference in its behaviour, mainly on how
emails are propagated.
Details:
- To check whether a participant is a seeker or building contact, we will fetch
participant
attributes
and check the participant role
# Sequence: Sending message to proxy email address
Only building contacts will receive emails to proxy email address.
Details:
- It's important for the programmatic message creation here to not trigger
Twilio's webhook. If the webhook is triggered, the building contact will get
the email that they have sent. Set
--x-twilio-webhook-enabled
tofalse
when the message is created. - Set
author
to the building contacts when messages are created, otherwise it'll shown as 'system' - The notification triggered by SES Receipt Rule will contain the building contact's email and body. We'll be able to derive the message from here.