Send Messages from Custom Objects
Info
Messaging from custom objects is available in Twilio for Salesforce version 4.129 and later.
Twilio for Salesforce supports 1:1 messaging from the Opportunity object and from any custom object in Salesforce.
This example sets up 1:1 messaging on the Opportunity object, but you can follow the same steps for any object.
Go to the record page and click Edit Page

Drag n Drop Twilio - Two Way Messages on your desired position in the page, and Activate & Save it

Go to Setup -> Object manager -> Twilio message -> Fields & relationships -> Click New
Select Datatype as Lookup Relationship and Click Next

Select the custom object, Opportunity in our case and Click next
Provide a name, set visibility in next screens and Save

This will connect our Twilio Message object to the custom object.
Go to Object manager -> Opportunity ->Fields & relationships -> Click New
- Select Datatype as phone field and click on Next button.
- Give the field name & click on Next button.
- Give Field level security to appropriate profiles & click on Next button.
- Add the field to pagelayouts & click on next button.
- Add it to all related lists & click on Save button.

Go to the custom object record page(we will go to Opportunity record for this example) and find the 1:1 messaging component
- Select a field to be used as the recipient's phone number (only field with phone number as data type are supported)
- Select the lookup field we just created on the message object in the previous step, to connect the component to the message object
- Click Save

You can now send and receive messages from the custom object
- Open "Twilio Configuration" tab.
- Navigate to "Inbox" section.
- Add "Opportunity" under "Message Owner and Related Record is Determined in the following Order: " section and rearrange the order.
- Click on Save button.
