A Mastodon compatible (Activity Pub) bot instance developed in PHP to quickly create and deploy multiple bots. I use the bots to regularly post interesting content (historical photos) to Mastodon.
Manual registration at large instances (like Mastodon.social) was slow: register -> verify -> create app -> add scopes... This tool helps to deploy bots (new ActivityPub accounts / identities) in couple of clicks.
See it in action: https://bots.ambience.sk/
- Pure PHP, no external dependencies.
- Apache server needed because of .htaccess rewrite rules. But these could be easily converted to NGINX.
- SQLite used as a database for low friction setup (database = single file).
- Setup a domain/subdomain with SSL certificate, where your ActivityPub (Mastodon compatible) instance will run, e.g.
bots.example.comorexample.com. - Download the code or
git clone https://github.com/nekromoff/mastodon-bots(to the root of domain/subdomain). - Continue to Setup your first bot below...
Multiuser (multibot) Fediverse instance. I recommend to host it on a domain or a subdomain. index.php is used to handle all traffic via rewrites.
Public facing website with list of bots and their posts including their profiles and full Mastodon compatible feeds.
Automatically generated based on the bots and their activity. Fully indexable by Google and other search engines. Verification via rel="me" included as well as bot creator META tag.
- Full administration panel - create and manage your bots (multiple bots per instance)
- Login: single admin user - authenticated via password only
- Bots - quick overview of bot activity and their stats
- create a bot
- edit a bot
- post as a bot
- social features - follow or block
- move - migration features - move from (alsoKnownAs) or to (movedTo) an instance
- Logs - log of all relevant events (incoming and outgoing) for all bots
- Settings - instance setup, log retention, media limits
Very simple API to communicate with your bots.
- Create a post
- Upload some media
- Post with media (use ID from upload response)
- Edit a post (but you can also do that manually via Admin)
- Delete a post (but you can also do that manually via Admin)
- Follow a remote account
- Open your instance at
example.com/admin/and set it up including admin password. - Log in using your admin password.
- Create New Bot, set username (no @ character), display name, short bio, password for the bot (keep it for later = API access)
- Edit your bot to enter additonal details (extra fields, featured hashtags) and upload your profile icon (avatar) and a header image. Set options such as discoverability, featuring in Mastodon explore, search engine indexing, followers approval. All options preset for full visibility.
- Go to Settings and change log retention and media upload limits as needed.
- See API Usage under settings for simple API communication with your bots.
Yes, no dependencies mean no need for
composer. SQLite database is just a file indata/folder, so no need to set up a separate database.
Yes, definitely. Just setup an SSL certificate and upload this code and you are good to go.
Once you are done with a first time setup, you can create a bot in about 20 seconds. You will need some more time to edit bio, upload profile image etc.
Yes, I built it to do just that!
API requests authenticate using bot username and password. You can use a custom script to post any content to Mastodon (ActivityPub). The API is very simple.
Example (creating a Mastodon / ActivityPub post):
curl -u botname:botpassword \
-X POST https://example.com/api/post \
-H "Content-Type: application/json" \
-d '{"content":"Hello Fediverse! #test","visibility":"public"}'
Yes, there is an admin UI to manually create, edit and delete posts.
Yes, although I wouldn't recommend it. There is no way for users (other than admin) to log in. All users would share common admin interface with a single password.
Note: Computer-assisted process was used to develop this code.
