99. How does the app relate the incoming messages to records in Salesforce ?
There are 2 ways in which Incoming gets associated with Salesforce records:
- Whenever you send a message to a new record, a Conversation Record gets created. Conversation is Parent Object to SMS History. Once the message is sent it will be attached to that Conversation. If you get a reply from that mobile number we check for Mobile Number and Sender id on the Conversation Object and attach it to the last created Conversation if there is any. If there is no Conversation for the Mobile Number and Sender id combination a new Conversation Record is created.
- Whenever a new incoming message is received, we check if this message is a response to an existing outgoing messages based on Phone number and sender id combination.If there are more than one such outgoing messages, we consider the response to be for the latest outgoing message. This message is looked up as previous message. If a previously sent outgoing message is found, we associate the incoming message with the same conversation as the previous outgoing message. If a previous message is not found, we find the number in all objects configured in Object Config and populate a lookup of all such objects. After this, our application applies a logic to identify the primary object to which this message should be associated with. Finally, a conversation is created / associated for the incoming message based on Phone Number, Sender Id, Primary Object, Primary Object Id and User criteria. if an existing conversation exists where all the 5 attributes match the incoming message, it is used to associate the new incoming message. If no such conversation exists, a new conversation is created.
Conversations in SMS-Magic Converse are created in the following way:
When an Outgoing message is sent if there are no Conversations with the same Mobile number, Sender id, Owner id, Object and record Id a new Conversation will get created. If there is an existing Conversation Record the Outgoing message will get attached to it. If any of the value (Mobile number, Sender id, Owner id, Object and record id) changes, a new Conversation record will get created.
Similarly when you receive an Incoming message, if there is a Conversation Record with the Mobile number and Sender id it will get attached to it. If there is no Conversation it will create a new one.