Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ“… 5/17 @ noon PT - Automating gr2m/helpdesk, Episode II #14

Closed
4 tasks done
gr2m opened this issue May 13, 2021 · 5 comments
Closed
4 tasks done

πŸ“… 5/17 @ noon PT - Automating gr2m/helpdesk, Episode II #14

gr2m opened this issue May 13, 2021 · 5 comments
Labels
automating helpdesk show Preparation issue for a live show

Comments

@gr2m
Copy link
Owner

gr2m commented May 13, 2021

πŸ’πŸ» Automating gr2m/helpdesk, Episode II
πŸ“… Monday, May 17th, 2021
πŸ• noon Pacific Time (in your timezone)
πŸŽ™οΈ no guests
🏷️ Automation


Subscribe to this issues to get a notification before the show begins and a summary after the show concludes.

Automating gr2m/helpdesk

I've laid out the current process for this repository at https://github.com/gr2m/helpdesk/tree/f085060fb98f61a005c9e79df15fdad6466c6a1a#how-i-use-this-repository. It's mostly manual. Time to spice it up a bit with some automation!

In this show, I'll try to automate the tweeting and comments on the issue belonging to the show.

Outline

  1. Quick review of what I've build so far in episode I
  2. Walkthrough of how I currently do the tweets and comments manually
  3. Figure out a way to automate it 😁

Preparation

Recording

image

Shownotes

@gr2m gr2m added the show Preparation issue for a live show label May 13, 2021
@gr2m
Copy link
Owner Author

gr2m commented May 17, 2021

Some notes ahead of the show 😁

In order to send scheduled tweets from your own account, you need to

  1. Register a GitHub App (these twitter-together docs might help
  2. Apply for the Twitter Ads API (these twitter-together docs might help

No idea why scheduling a tweet requires access to a dedicated Ads API but here we are. The twitter-together docs might be outdated, twitter is changing things all the time. pull requests welcome :)

Here are some snippets.

instantiate twitter and set userId and add account ID

const Twitter = require("twitter");
const twitter = new Twitter({
  consumer_key: process.env.TWITTER_CONSUMER_KEY,
  consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
  access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY,
  access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
});

// get account ID at https://ads.twitter.com/, press on "Create an ad", then
// copy the part the 2nd segment of the URL path, e.g.
// https://ads.twitter.com/onboarding/6zy0c/welcome?onboarding=true => 6zy0c
const accountId = "6zy0c";

// Get your Twitter account's user ID at https://codeofaninja.com/tools/find-twitter-id
const userId = "11754732";

List scheduled tweets

twitter.get(
  `https://ads-api.twitter.com/9/accounts/${accountId}/scheduled_tweets`,
  (error, result) => {
    if (error) {
      console.log(error);
      return;
    }

    console.log(result);
  }
);

Create a new scheduled tweet

twitter.post(
  `https://ads-api.twitter.com/9/accounts/${accountId}/scheduled_tweets`,
  {
    scheduled_at: "2021-05-17T18:30:00Z",
    as_user_id: userId,
    text:
      "πŸ”΄ Going live in 30 minutes: Automating gr2m/helpdesk, Episode II\n\nhttps://github.com/gr2m/helpdesk/issues/14",
    nullcast: true,
  },
  (error, result) => {
    if (error) {
      console.log(`error`);
      console.log(error);
      return;
    }

    console.log(result);
  }
);

@gr2m
Copy link
Owner Author

gr2m commented May 17, 2021

Twitter API documentation for scheduled tweets:
https://developer.twitter.com/en/docs/twitter-ads-api/creatives/api-reference/scheduled-tweets

@gr2m gr2m changed the title πŸ“… 5/17 @ noon PT - Automating gr2m/helpdesk, Episode II πŸ“… 5/17 @ noon PT - Automating gr2m/helpdesk, Episode II - twitter edition May 17, 2021
@gr2m gr2m changed the title πŸ“… 5/17 @ noon PT - Automating gr2m/helpdesk, Episode II - twitter edition πŸ“… 5/17 @ noon PT - Automating gr2m/helpdesk, Episode II May 17, 2021
@gr2m
Copy link
Owner Author

gr2m commented May 17, 2021

I mentioned https://github.com/octokit/webhooks/ in the show. It has very complete JSON schemas and payload examples for all of GitHub's webhook event requests. Much more complete than what GitHub has on its own developer docs. It's a great @octokit community initiative by @wolfy1339 and other contributors

@gr2m
Copy link
Owner Author

gr2m commented May 17, 2021

Recording is now available on twitch: https://www.twitch.tv/videos/1026105427

image

@gr2m
Copy link
Owner Author

gr2m commented May 17, 2021

The video is now archived on YouTube: https://youtu.be/9Y68cC7nR68

Feel free to add comments if you have more questions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automating helpdesk show Preparation issue for a live show
Projects
None yet
Development

No branches or pull requests

1 participant