A common use cases is to convert the lead into contact or opportunity and in the same time we can push the lead conversation into the newly converted contact or opportunity’s record.
Before going into setup, we just need to understand how messages are stored and how they are linked to the record/s.
Each incoming and outgoing message is stored into the message bucket object in salesforce.
In the message bucket, are stored the related Salesforce ID records under the “related to” field and at the same time the system automatically fills the “related lookup” field in the message bucket record.
You might see other lookup fields in the message bucket like contact, lead, opportunity, and account. However, you can ever create a lookup field with any other object in the salesforce.
If the message bucket is linked to for example [Contact A] then it will show the messages in mini chat console that is related to [Contact A].
The same message bucket can be linked to multiple lookup records, meaning that it it will show the messages in all of the related lookup records. Ex: If one message bucket is linked to a lead and a contact then you can see the same message in the specific lead and contact.
In the conversation, we are going to query all the messages related to the lead and update the related to field and \ the contact lookup with the newly created contact.
Note: Run Your flow Asynchronously.
Step 1: Write a flow on “Lead object”
Step 2: Configure Trigger “A record is Updated”
Step 3: Enter conditions as shown in below. >>> Click “Done”.
Step 4: Add get record element to your flow and match the ID. With Current record à converted Opportunity ID. >>> Click “Done”
Step 5: Add “get record” element to flow as show below.
Step 6: Add a “Loop” element to the flow and follow the next image. >>> Click “Done”
Step 7: Add “Update records” inside the loop in flow as shown below >>> Click “Done”
This is how the final flow should look like: