Getting Started
@skyware/bot
makes it easy to build bots for Bluesky. This guide will walk you getting set up and making your first post.
Setting up
Note that you will need an existing Bluesky account for the bot to log in to.
Once you have created an account and taken note of your credentials, it’s recommended to store them in a .env
file in the root of your project. You can use the dotenv
package to load these credentials into your project.
Logging in
To log in,
When calling new Bot()
, you may choose to pass an optional BotPostOptions object to configure the bot. This object can contain the following properties:
service
: The PDS to log into. Defaults tohttps://bsky.social
.langs
: An array of two-letter language codes signifying the languages the bot will post in. Clients may use this information to show users posts in languages they understand, and to offer the option to translate a post. Defaults to["en"]
.emitEvents
: Whether the bot should emit events. You’ll learn more about this in Listening to events. Defaults totrue
.- and various other configuration options — refer to the BotPostOptions documentation for the full list.
Posting
Making a post is just as simple.
Refer to the Bot#post method documentation for more information on the available options.
If the post is successful, you should see its URI logged to your console.
You may notice that the URI begins with at://
. This is an AT URI, used by AT Protocol applications to refer to data, such as posts, follows, and lists. More on this in the glossary!