Is there a relatively simple way to make a link that opens Instagram DM with a specific message, such as "website.com/blog/+slug"?
Yes, it is possible to create a link that opens Instagram DM with a specific message. However, please note that this functionality is only available on the Instagram mobile app, not on the web.
To create a link that opens Instagram DM with a specific message, you can use the following format:
https://www.instagram.com/direct/t/{user_id}?text={message}
Here's how you can create a link with a specific message:
- Determine the user ID: To find the user ID of the person you want to send the message to, you can visit their Instagram profile on the web and check the URL. The user ID will be the string of numbers between "instagram.com" and "/".
For example, if the person's Instagram profile URL is https://www.instagram.com/johndoe/
, the user ID would be johndoe
.
Encode the message: Next, you'll need to encode the specific message text. You can use the
encodeURIComponent()
function in JavaScript to do this. For example, if you want the message to be "website.com/blog/+slug", the encoded version would be "%20website.com%2Fblog%2F%2Bslug".Create the link: Finally, you can combine the user ID and encoded message to create the link. Replace
{user_id}
with the user ID you obtained in step 1, and replace{message}
with the encoded message.
For example, if the user ID is johndoe
and the encoded message is "%20website.com%2Fblog%2F%2Bslug", the final link would be:
https://www.instagram.com/direct/t/johndoe?text=%20website.com%2Fblog%2F%2Bslug
When a user clicks on this link on a mobile device with the Instagram app installed, it will open Instagram Direct with a new message containing the specified text.
Please note that this method relies on the current behavior of the Instagram app and is subject to change.