Moving my Twitterbot @kevinhookebot to Mastodon

I mentioned a few days back that I’ve started to look at migrating some of my Twitter bot projects over to Mastodon, specifically to the Mastondon server. Over the past few years I’ve deployed a number of bots that have been running continually for a number of years now without any updates. My motivation to move away from patronizing Twitter since the buyout is that it’s not a place I want to hang out anymore, but also I have some tech updates I need to take care of for these bots. A few of them I deployed 5 years ago and the AWS Lambda runtimes they were deployed with are now long past their support and have long been deprecated.

The main Lambda for @kevinhookebot was deployed originally in 2017 but updated at some point at least once in 2018:

The Lambda that watches for replies to a Tweet and replies automatically I don’t think has been updated since it was first deployed, and has been running on the Node6 runtime since 2017:

Both of these need to get redeployed with a later/supported runtime and also moved to using the Servlerless framework to help automate the deploys. It’s also odd that given that I share most of my hobby projects on Github, neither of these were committed to a repo anywhere, so first steps were to commit the original source to Github, and then starting making my updates.

First Steps

Before completely retiring the Twitter accounts, I’m going to update most of these to either cross-post to Twitter and Mastodon, or fork a Mastodon version and keep both running for a while, then eventually I’ll close the accounts on Twitter later.

For first steps, updating @kevinhookebot has to add integration with Mastondon’s apis to post a status update. I’ve got some learning to do with the apis and the authentication approach, but so far using the mastondon-api npm module, posting a status update is as simple as:

let Mastodon = require('mastodon-api');
let config = require('./config/config-mastodon.json');

exports.postMastodon = (item) => {

    const M = new Mastodon({
        access_token: config['access-token'],
        api_url: '',
    });'statuses', {
        "status" : item.tweettext
        .then((resp) => console.log(;


I still have to things to work out, like how to query replies to a Toot that I’ll need to support some of my other interactive bots, but so far so good.

AWS DynamoDB error: ValidationException: One or more parameter values were invalid: Condition parameter type does not match schema type

Executing a query against a Global Secondary Index I got this error:

ValidationException: One or more parameter values were invalid: Condition parameter type does not match schema type

Using the NodeJS Document api, my query looked like this:

let params = {
        "TableName": "exampletable",
        "IndexName": "example-createdate-index",
        "KeyConditionExpression": "exampleattr1 = :exampleattr1",
        "ExpressionAttributeValues": {
            ":exampleattr1": { "S": "0" }
        "ProjectionExpression": "createdate, exampletext",
        "ScanIndexForward": false
return docClient.query(params).promise();

The error is saying that one of my query parameter types does not match the values in the schema. I know this value is a String so this looks correct. Following recommendations on this question, it’s suggested to not pass the param type as “S” and let the Document api work out the type itself.Remove the “S” and just passed the value and now it’s working as expected.

gp-pages deploy fails when run from GitHub Action: Author identity unknown

I’m calling gh-pages from a GitHub Action, and at the point when gh-pages is called by the Action, it fails with this error:

> gh-pages -d build

Author identity unknown

*** Please tell me who you are.

Following this recommendation on a similar posted issue, I updated the ‘npm run build’ script in my package.json to pass the -u option with the github-actions-bot userid:

    "deploy": "gh-pages -d build -u 'github-actions-bot <>'",

After adding this and re-running, now I have a different error:

> gh-pages -d build -u 'github-actions-bot <>'

fatal: could not read Username for '': No such device or address

Apparently to allow the Action to use actions/checkout to access your repo you must use a Personal Token per additional instructions here.

To create a new access token, access your account settings, then Developer Settings:

To add the token value as a secret to your project, add a new secret via settings on the repo that your Action is accessing:

After paying more attention to the Action log, the checkout step was actually working and completing as expected, it was the ‘npm run deploy’ step that was failing with same error as shown in the linked post above. Following the same advice to use the access token to resolve the ‘Could not read username’ error, I updated the ci.yml again to add the reference to the token as part of setting the remote repo url:

- name: Deploy
    MY_NAME: kevinhooke
  run: |
    git config --global $MY_EMAIL
    git config --global $MY_NAME
    git remote set-url origin https://$MY_NAME:${{ secrets.GH_SECRET }}
    npm run deploy
  • the git config steps set the git user’s email and name properties within the context of the Github Action
  • the ‘git remote set-url’ specifies the repo url including my userid and the Personal Access Token retrieved from the GitHub Secret.

Problem solved, now the action works as expected and publishes this project’s GitHub pages on every commit!