PublishTo.Dev: Scheduling article publishing on dev.to
Tags: showdev, javascript, discuss, productivity
Published: 2019-07-30 14:35:33

It's 11 PM.

You've finally put the finishing touches on your next masterpiece article on dev.to. You can't wait to share it with the world and start collecting those ❤️ and 🦄.

You move your cursor to that 'Publish' button, but then pause...

Should you publish the article now and risk getting buried in the morning's headlines? Should you set an alarm and try to remember to return to your draft and click 'Publish' at the [right moment](https://www.blogtyrant.com/best-time-to-publish-blog-articles/)?

It's a conundrum and it's too late to think this hard.

I have a solution: [PublishTo.Dev](https://www.publishto.dev). A simple tool for dev.to authors that lets you choose the exact date and time you want your draft article to go live. Just choose a time, schedule your article, and go to bed knowing your content will land at the perfect time.

![](https://thepracticaldev.s3.amazonaws.com/i/s0esj4txnzc71dgxx8hj.gif)

## What is PublishTo.Dev?
At its core, [PublishTo.Dev](https://www.publishto.dev) is a scheduling service for dev.to authors. It uses the recently introduced [dev.to API](https://dev.to/api) to publish draft articles on a specific date and time. Well, I'll let this video explain.

{% youtube 8y9piBXwXts %}

There are 3 primary components of this service:

1. A [browser extension](https://chrome.google.com/webstore/detail/publishtodev-extension/bohbnpnialpdpgnibbddaaoaklmnjoaa) used for scheduling articles
0. An Azure serverless backend that handles the scheduling
0. A [static site](https://www.publishto.dev) to review/cancel scheduled postings

The browser extension works with both Google Chrome and Microsoft Edge Insider. The extension can be installed directly from the [Chrome Web Store](https://chrome.google.com/webstore/detail/publishtodev-extension/bohbnpnialpdpgnibbddaaoaklmnjoaa) (and eventually Microsoft Edge Extension store), OR loaded "unpacked" from the [GitHub source](https://github.com/toddanglin/PublishToDev).

PublishTo.Dev does **not** attempt to change the article authoring experience. It works on saved, unpublished drafts that have already been authored using existing tools. PublishTo.Dev is focused exclusively on scheduling articles. 

### The scheduling process
Let's take a look at how you schedule a draft article using PublishTo.Dev.

#### Setup
First, you need to install the browser extension. Follow the instructions in the GitHub repo or (if you're using Chrome) just [install from the Store](https://chrome.google.com/webstore/detail/publishtodev-extension/bohbnpnialpdpgnibbddaaoaklmnjoaa).

![](https://thepracticaldev.s3.amazonaws.com/i/spggoi0cjnxgbbm2n3pj.png)

With the extension installed, there is a one-time configuration step to add your unique dev.to API access token. This is how PublishTo.Dev publishes on your behalf. Right-click on the extension icon in the browser and choose 'Options'. Alternatively, you can navigate to `chrome://extensions` or `edge://extensions` to get to the options page, too.

![](https://thepracticaldev.s3.amazonaws.com/i/u3mn3djjajicdfinehea.png)

Here, you are asked for your API access token.

![](https://thepracticaldev.s3.amazonaws.com/i/qj9gara9y9akaowj3z7d.png)

To get that, navigate to the [settings account page](https://dev.to/settings/account) on dev.to and generate a new token for PublishTo.Dev. Copy the token value and it to the extension options.

![](https://thepracticaldev.s3.amazonaws.com/i/3lo57iaxvt0g221uoh6m.png)

#### Scheduling
Now that you're all set up, let's schedule an article.

Navigate to a saved draft. You know you're on the right page when you see the big, red "Unpublished" banner at the top of your article. From here, click the browser extension icon and choose the date and time you want the article to go live.

![](https://thepracticaldev.s3.amazonaws.com/i/k6vhy8fv4np3lfxe5xcl.png)

**Note:** The selected publishing time must be in the future (obviously), up to 30 days from now. That is an arbitrary limit that may be removed in the future, but for now, articles can be scheduled up to a month in advance. When choosing a time, specific hours or minutes can be directly input in the calendar text boxes.

With your date and time selected, click "Schedule Post."

![](https://thepracticaldev.s3.amazonaws.com/i/pr5e68hfqpndhuclm4bq.png)

If all goes well, you'll see a confirmation message in the extension pop-up.

#### Rescheduling
Oops! You just remembered that _Wednesdays_ are better for your content than _Mondays_. How do you change your publishing schedule?

Simple. Just revisit the unpublished draft that needs to be rescheduled, and follow the original process. As long as the article has not yet been published, the new scheduled time will override the previous schedule.

### Reviewing and Cancelling Schedules
While the browser extension is used for all article scheduling, a [separate website is available](https://www.publishto.dev) for reviewing the status of scheduled articles.

To use the website, simply enter the same dev.to API access token configured with your browser extension and click "Get Scheduled Posts."

![](https://thepracticaldev.s3.amazonaws.com/i/2vvta3zprv9hgv6wetwh.png)

If you have scheduled articles, they will be displayed along with one of the following status indicators:

- **Published:** Successfully published scheduled article
- **Pending:** Article waiting to publish at scheduled time
- **Failed:** Something went wrong and the article did not publish at scheduled time
- **Cancelled:** Scheduled publishing was cancelled by the author (you)

Any article in the **Pending** state can be cancelled if you no longer want it to be published automatically. Just click the "Cancel" button on the row for that post.

![](https://thepracticaldev.s3.amazonaws.com/i/afnco9pcuco8ai59ztjf.png)

If you decide to reschedule a **Cancelled** post in the future, just follow the original scheduling process and the article will be rescheduled. The only state that is "final" is **Published.** A published post cannot be republished or unpublished using PublishTo.Dev.

## How does this work?
Behind the scenes, the heavy lifting for PublishTo.Dev is made possible by [Azure Durable Functions](https://cda.ms/10S). Durable Functions are perfectly suited for dealing with long-running, async tasks, only actively running (and billing) when something needs to be done between periods of waiting. The wait could be seconds, minutes, hours, days...or longer*.

_(*Durable function timers [cannot last longer than 7 days today](https://cda.ms/111), BUT...that is a limit that's being removed AND there are workarounds today for setting longer timers. I'll get in to that in another post.)_

In the case of PublishTo.Dev, a serverless function runs when an article is initially scheduled, and then using a [durable function timer](https://cda.ms/10T), "hibernates" until it's time to publish the post. This eliminates the need to do any kind of interval polling to know when a post needs to be published.

![](https://thepracticaldev.s3.amazonaws.com/i/6f94d9iqctknc858p66q.png)

When the scheduled publish time arrives, the durable function automatically wakes up and tries to publish the post using the dev.to API.

Durable functions are good for many different kinds of long-running, async scenarios. In fact, the [docs highlight six common scenarios](https://cda.ms/10W), like chaining async functions or even [waiting on human input](https://cda.ms/10X), where durable functions make your life much easier.

In future articles, I will expand on the technical implementation of PublishTo.Dev. Stay tuned for that.

## Putting it all together
From the outset, the goal was to provide an easy way to schedule post publishing, and PublishTo.Dev accomplishes that. Or, it does for me.

Let me know what you think. How does it work for you? How can it be a more useful utility?

One day, I fully expect dev.to will support native post scheduling and eliminate the need for this tool, but until then, I hope it helps you improve your publishing workflow.