Set a default welcome message in Twitter DM
👋

Set a default welcome message in Twitter DM

Twitter has a feature to allow you to set a default welcome message in your DM. For example, this is mine:

image

The catch: you have to set it up via API.

The steps

To save you some time, here are what you need to do (the easiest way):

⚠️

Disclaimer: make sure you understand every command you run.

Install twurl:

gem install twurl

Authorize (You need a Twitter V1 developer account with an app with "Read + Write + Direct Messages" permission):

twurl authorize --consumer-key KEY \
                --consumer-secret SECRET

Then follow the instruction to authorize.

Next, create a welcome message (change the CHANGE THIS string to your own message):

twurl -A 'Content-type: application/json' /1.1/direct_messages/welcome_messages/new.json -d '{"name": "simple_welcome-message", "welcome_message": {"message_data": {"text": "CHANGE THIS"}}}'

You will receive something like this in the response. Copy the ID.

image

Set the welcome message as "default":

twurl -A 'Content-type: application/json' -X POST /1.1/direct_messages/welcome_messages/rules/new.json -d '{"welcome_message_rule": {"welcome_message_id": "PASTE_THE_ID_HERE"}}'

That's all. You are all set! 🎉

Remove the message

List the rules:

twurl -X GET "/1.1/direct_messages/welcome_messages/rules/list.json"

Then find the rule ID (there should only be 1 rule).

Delete the rule:

twurl -X DELETE "/1.1/direct_messages/welcome_messages/rules/destroy.json?id=RULE_ID_HERE"

Now your default message is gone.

👋 Like what you read here?

Hello there, I'm Tony Dinh.

image

I quit my high paying job to work on my side projects with a mission to make a living from my apps and live an independent life. 🌴

❤️ Thanks for reading!