Message creation flow
Clicking the button will link the user to the Direct Message composer, pre-populated with the values you define in the button markup.How to add a message button to your website
publish.x.com is a simple configuration tool for to create a message button. Just enter your @screenName to get started.Manually
- Create an anchor element with a
twitter-dm-buttonclass name. Set ahrefattribute value ofhttps://x.com/messages/composeto create a link to the X direct message view. Therecipient_idquery parameter is the ID of the @username that should receive the messages.
- Optionally pre-populate message text by customizing the
textquery parameter.
- Asynchronously load the X for Websites JavaScript using our loading snippet. The script will initialize the message button after your page content loads.
Query parameters
| Parameter | Description |
|---|---|
recipient_id | Required. The user ID of the X user that will receive the messages. |
text | Optional. The pre-populated text in the message. Text must be URL encoded. |
Button customization
Size
Add adata-size attribute value of large to display a larger message button.