It's an AT Protocol Firehose consumer service built for Bluesky. This consumer was built with the intention of allowing developers to deploy multiple Bluesky bots as serverless functions, saving them from having to deploy each bot as a long-running instance on a cloud provider. Hence, with this approach, multiple bots can listen to the same firehose consumer service, potentially saving costs of cloud provider usage.
It uses the Firehose listener from @skyware/firehose
to listen to all commits on the Relay and verifies if there's a mention ("@") to any of the accounts configured in the ACCOUNTS
json string that's set as an environment variable. If there's a mention, then it calls the webhook URL associated to that account.
It also persists the latest cursor value in case of an error. Then, when the listeners restarts, it fetches the stored cursor and starts to listen from that point - ensuring that no commits are lost.
To communicate with the DB we use the DynamoDB client.
{
"action": "create",
"path": "app.bsky.feed.post/3l3seo55pbh24",
"cid": ...,
"record": {
"text": "@handle.bsky.social test",
"$type": "app.bsky.feed.post",
"langs": [
"en"
],
"facets": [
{
"$type": "app.bsky.richtext.facet",
"index": {
"byteEnd": 28,
"byteStart": 0
},
"features": [
{
"did": "did:plc:7qnf6kxpgvzp57gzz3vbflt6",
"$type": "app.bsky.richtext.facet#mention"
}
]
}
],
"createdAt": "2024-09-10T12:03:09.403Z"
},
"uri": "at://did:plc:vzwb6a6lqj5flfcneiyx6a6j/app.bsky.feed.post/3l3seo55pbh24"
}
The recommended deployment setup is to deploy the service on AWS ECS (Fargate) and utilize AWS Dynamo DB to persist the cursor.
This service was built to be deployed on AWS, deploying it to another cloud provider will require some changes on:
- package.json scripts
- DB setup (
db.ts
)