• Home
  • My Favorite Topics
    • Blogging
    • Business
    • Career
    • Cars
    • Consulting
    • Epic Life Quest
    • Iceland
    • Marketing
    • Presenting
    • Productivity
  • My Life Quest
    • Future Achievements
  • About Me
  • My Recent Photos

How to Automatically Tweet Your Stack Overflow Answers with Zapier

5 years ago
stackoverflow
No Comments

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:

The Eureka moment

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:

  • http://stack2rss.quickmediasolutions.com/2.2/users/26837/answers?site=stackoverflow
  • http://stack2rss.quickmediasolutions.com/2.2/users/426/answers?site=dba

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:

New tweet contents

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.

stackoverflow
Previous Post
Using Slack for Conference Session Q&A
Next Post
How to Understand Where a Software Vendor Employee is Coming From

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Hi. I’m Brent.

That's me, Brent.

I live in Las Vegas, Nevada. I'm on an epic life quest to have fun and make a difference.

I co-founded Brent Ozar Unlimited to help make your SQL Server go faster. I also maintain sp_Blitz® and the open source First Responder Kit repo.

My current car collection includes a Jaguar XKR-S, Porsche 944 Turbo, Porsche 356 Speedster replica, and a Ferrari 328 GTS.

profile for Brent Ozar on Stack Exchange, a network of free, community-driven Q&A sites

© 2021 Brent Ozar, all rights reserved. Privacy Policy

  • Home
  • My Favorite Topics
  • My Life Quest
  • About Me
  • My Recent Photos