Closed gr2m closed 3 years ago
Some notes ahead of the show π
In order to send scheduled tweets from your own account, you need to
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.
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";
twitter.get(
`https://ads-api.twitter.com/9/accounts/${accountId}/scheduled_tweets`,
(error, result) => {
if (error) {
console.log(error);
return;
}
console.log(result);
}
);
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);
}
);
Twitter API documentation for scheduled tweets: https://developer.twitter.com/en/docs/twitter-ads-api/creatives/api-reference/scheduled-tweets
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
Recording is now available on twitch: https://www.twitch.tv/videos/1026105427
The video is now archived on YouTube: https://youtu.be/9Y68cC7nR68
Feel free to add comments if you have more questions
ππ» 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
Preparation
Recording
Shownotes
twitter
package