# Send Messages from Custom Objects

> \[!NOTE]
>
> Ability to setup messaging from custom objects is available version **4.129 onwards**

Now Twilio for Salesforce allows you to do 1:1 messaging from Opportunity & from any custom object

For this example, we will setup 1:1 messaging on the opportunity object.

But you can do this for any object in Salesforce

## Add 1:1 Messaging Component to Page Layout

Go to the record page and click Edit Page

![Salesforce setup showing opportunity mobile field with phone data type.](https://docs-resources.prod.twilio.com/3b83ce10376b645df2835483f66771d0668462d1ff0c406bb953826e93035fa5.png)

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

![Salesforce opportunity page with Twilio integration panel for message settings.](https://docs-resources.prod.twilio.com/ebbdb64901db32dfc3bec158831ea7ea1b0121154327ca650cb850ee0456f7c8.png)

## Setup relationship between Twilio message Object and Custom Object

Go to Setup -> Object manager -> Twilio message -> Fields & relationships -> Click *New*

Select Datatype as *Lookup Relationship* and *Click Next*

![Select Lookup Relationship under Data Type in Twilio Message setup.](https://docs-resources.prod.twilio.com/b180b814159a7dbacb3510cea806e5313c8405a84d16ac04f60107a4ae0ff211.png)

Select the custom object, *Opportunity* in our case and Click next

Provide a name, set visibility in next screens and Save

![Select 'Opportunity' from the dropdown to choose the related object, then click 'Next'.](https://docs-resources.prod.twilio.com/2cae083173d4997d84de4dbda896b9c7619c2270af20e8f0f60e7c3d3e7ef4e4.png)

*This will connect our Twilio Message object to the custom object.*

## Create a custom field to store the mobile number of opportunity

Go to Object manager -> Opportunity ->Fields & relationships -> Click *New*

1. Select Datatype as phone field and click on Next button.
2. Give the field name & click on Next button.
3. Give Field level security to appropriate profiles & click on Next button.
4. Add the field to pagelayouts & click on next button.
5. Add it to all related lists & click on Save button.

![Custom field to store the mobile number of opportunity.](https://docs-resources.prod.twilio.com/0974214d053abfc64e3af68bb476f6f7dfe820a17c0dd4016e7d985a8aad70fb.png)

## Update Component Setting in the Custom Object

Go to the custom object record page(we will go to Opportunity record for this example) and find the 1:1 messaging component

1. Select a field to be used as the recipient's phone number (only field with *phone number* as data type are supported)
2. Select the lookup field we just created on the message object in the previous step, to connect the component to the message object
3. Click Save

![Twilio configuration for message ownership by contact or lead owner with opportunity selection.](https://docs-resources.prod.twilio.com/2b8196aa413d9a2e08ed5d94323234be7957f42c6392d6c9b5fa3e796fc3f5e3.png)

You can now send and receive messages from the custom object

## Add opportunity for message ownership & lookup population

1. Open "Twilio Configuration" tab.
2. Navigate to "Inbox" section.
3. Add "Opportunity" under "**Message Owner and Related Record is Determined in the following Order:** " section and rearrange the order.
4. Click on Save button.

![Message ownership for opportunity.](https://docs-resources.prod.twilio.com/02f06c41e5a419d2b7966ab2bfca3a947a357043964e6c4d44f797baeac397fe.png)
