Search Icon, Magnifying Glass

Marmanold.com

Graduation Cap Heart Question Mark Magnifying Glass

Drafts 5 Sermon Prep with LectServe

Drafts 5 for Mac recently introduced the ability to do some basic scripting in JavaScript as an action in the application. Each time I prepare a sermon, the first step for me is to lookup the readings for the week on LectServe and then paste the readings into Drafts where I can start doing sermon preparation and, eventually, write my sermon. As soon as I saw actions and scripting introduced for Drafts, I knew I’d have to automate my sermon prep process.

Automating Drafts to pull down the text of the readings for the week is simple. First, click Actions in the menubar and then select Manage Actions. Press the add action button circled in red and then select Add Action in the popup.

Step 1

In the Edit Action windws select Script from the dropdown menu and then click the plus to add a new script action.

Step 2

Next, click on the Script action and click the edit button.

Step 3

If you’ve done everything correctly, you’ll now see an editor window where you can write out a script.

Step 4

Paste the below code into the editor window and you’ll basically have everything you need to automate your weekly sermon prep. It hits LectServe’s API to get the upcoming Sunday’s readings from the ACNA lectionary and then looks ups the text of the readings via the ESV API. The only modification you’ll need to make is getting your own API token from Crossway. That’s documented on their website and very easy to do.

    var http = HTTP.create();

    let esvBase = "https://api.esv.org/v3/passage/text/";
    let esvOpts = "&include-passage-references=false&include-verse-numbers=false&include-footnotes=false&include-footnote-body=false&include-headings=false";
    let esvAPI = "Token xxxxxxxx";

    let lectResp = http.request({
        "url": "https://lectserve.com/sunday",
        "method": "GET"
    });

    let d = Draft.create();
    let lectRespData = JSON.parse(lectResp.responseText);

    d.title = lectRespData.services[0].name;
    d.addTag("sermon");

    var finalDraft = "";
    finalDraft += "# " + lectRespData.services[0].name + "\n";
    finalDraft += lectRespData.date_pretty + "\n\n"

    for (reading of lectRespData.services[0].readings) {
        finalDraft += "## " + reading + "\n\n";

        let encodedRef = encodeURI(reading);

        let esvReading = http.request({
            "url": esvBase+"?q="+encodedRef+esvOpts,
            "method": "GET",
            "headers": {
                "Accept":"application/json",
                "Authorization": esvAPI
            }
        });

        finalDraft += JSON.parse(esvReading.responseText).passages.join(" […] ") + "\n\n";
    }

    d.content = finalDraft;
    d.update();
    d.saveVersion();