In our company Slack chat, we have a bot that alerts us whenever there’s a new SQL Server question at DBA.StackExchange.com.
One day, a question came in, Erik got to thinking, and I went a-Googling:
First, get your user ID # for the site you want to use (Stack Overflow, DBA.StackExchange.com, etc.) It’s in the URL for your user profile page – click on your user icon at the top of any Stack page, and it’ll take you to your profile. For example:
- My Stack profile page: https://stackoverflow.com/users/26837/brent-ozar – which means my Stack user ID is 26837, but
- My DBA.StackExchange.com profile page: https://dba.stackexchange.com/users/426/brent-ozar – which means my DBA.se user ID is 426
Log into Zapier.com and start a new zap. If you don’t already use Zapier, you could try something similar with IFTTT.com or Microsoft Flow. I’m gonna use Zapier since that’s the tool I use for this kind of thing, but feel free to leave instructions in the comments if you’ve got a different way to do it.
For the trigger, choose RSS by Zapier. By default, the new action type is New Item in Feed, but show the less-common options and pick New Items in Multiple Feeds. For the source feed, we’re going to use the very cool Stack2RSS service:
That first one is my Stack Overflow answers feed (site = stackoverflow, and my ID# for that site) and the second one is my DBA.StackExchange.com answers feed.
For the first action, choose Formatter. We need to trim down the answer titles in case they’re too long. Choose Formatter, Text, Truncate. For the input value, choose Step1’s Title, and trim it down to 100 characters.
For the next action, choose Twitter, Create Tweet. If you haven’t connected your Twitter account to Zapier yet, you’ll have to go through some setup. For the tweet’s contents, here’s what I use:
Note that in mine, I’m only tweeting my DBA.se answers here – you could customize your tweet intro text to say whatever you want. (Now you see why you’ll definitely need to truncate the tweet contents.)
The Step2.Title field refers to your trimmed/truncated title.
The Step1.Link is your answer’s link, and there’s a catch. If you let Zapier shorten the URL, then the link will go directly to your answer (and not show the question). If you don’t let Zapier shorten it, then due to a bug somewhere (Zapier, Twitter, something’s API, who knows) then sometimes the links don’t work at all – they just go to the root page like https://dba.stackexchange.com rather than the specific question. (sigh) Ah, the Internets.
And you’re done! For bonus points, you could also integrate Facebook, LinkedIn, Google+, or use Buffer to manage it all for you.
At first I felt guilty when we went live with it, sharing our answers on social media. But then I realized I’ve read entire blog posts that have less evidence and detail than Erik’s Stack answers.