- Be a Beeper user
- Python > 3.7
- Docker
- yarn
- following these steps I ran the docker container to create a Maubot server on my local machine
- an unspoken but relevant step here is to create a user that you’ll log into your Maubot Manager interface with. do this line 86 of
config.yaml
. For examplemyUser: somePasswordHere
- re-run the docker container after that and you should be able to visit
http://localhost:29316/_matrix/maubot
and login with the above user
- an unspoken but relevant step here is to create a user that you’ll log into your Maubot Manager interface with. do this line 86 of
- next I created a dummy matrix account - this is the identity that my first bot will use to send messages on the matrix network.
- navigate to app.element.io, and create a new account. call it
yournameTestBot
or something
- navigate to app.element.io, and create a new account. call it
- then I connected my maubot server to my dummy matrix account
- you’ll need to install the maubot cli for this. keep the your docker container running, and in the same directory that you started your docker container from, run steps 1-3 of “Production Setup” here to install the cli
- run
mbc login
and use the credentials that you created in yourconfig.yaml
- run
mbc auth
. use “matrix.org” as the homeserver, and use the username and password for your dummy matrix account on element.io. take note of the output, you’ll need it in a sec. - in a different directory, clone the echo bot plugin. any maubot plugin would have worked here, but echo is simple and lightweight so it makes a good starting point. after cloning, run
zip -9r plugin.mbp *
to compile it into the necessary file format for uploading. - then I opened
http://localhost:29316/_matrix/maubot
and connected the dots.- Click plugins on the sidebar and upload
plugin.mpb
from your echo directory - Click clients on the sidebar
- your User ID you can grab from your element.io account - it’ll be
@yournameTestBot:matrix.org
if you’re following the same format I am - Homeserver should be matrix.org
- Fill in access token and device ID from the output of the
mbc auth
command above - Pick whatever display name you’d like and save!
- your User ID you can grab from your element.io account - it’ll be
- Click instances in the sidebar and name give it whatever ID you’d like. Then make the primary user the client you just created, and make the type the plugin you’ve uploaded. Save that
- Click plugins on the sidebar and upload
- ok so my test bot was actively running on the matrix network - now I wanted to interact with it
- in beeper, create “new beeper chat” (command k → new beeper chat) then search for the user id of the client you set up -
yournameTestBot:matrix.org
if you’re following my format) - it should populate with the display name of that bot. click that, start a chat, and type !ping
- in element.io, you should be able to see the !ping message you sent from beeper come through to your matrix account. your bot should automatically respond with the corresponding “pong” back.
- in beeper, create “new beeper chat” (command k → new beeper chat) then search for the user id of the client you set up -
ok - the echo bot is now effectively receiving and sending messages from my dummy matrix account. now I want it to do the same from my beeper account
-
edit the
config.yaml
to include beeper.com as a homeserver. IE thehomeservers
block in your config file should look like:homeservers: beeper.com: url: https://matrix.beeper.com matrix.org: url: https://matrix-client.matrix.org
-
re-run
mbc auth
and this time use beeper.com as the homeserver. use your beeper username and password to login. take note of the output -
restart your docker container
docker run --restart unless-stopped -p 29316:29316 -v $PWD:/data:z dock.mau.dev/maubot/maubot:latest
-
go to your matrix manager in your browser
- create a new client. use beeper.com as the homeserver (it should appear in the dropdown), and input the access token and device ID from the output of
mbc auth
use whatever you like for the id, but note that when people find you on beeper, this id and display name will show up - create a new instance. use whatever id you like, and connect it from your new beeper client to the existing echo bot plugin
- create a new client. use beeper.com as the homeserver (it should appear in the dropdown), and input the access token and device ID from the output of
-
send yourself an iMessage “!ping” and your bot will attempt to respond, but fail. it needs to be verified.
- do this by going into beeper, cmd k → “new beeper chat” and type in any username (doesn’t matter you won’t actually send them anything)
- click “info” in the top right → “people” and then click to verify the maubot instance running with your account credentials.
-
try again and you should find that you respond to anyone who iMessages you “!ping” with “!pong”, without you typing anything!
ok - time to actually build my bot. I used the echo bot as a starting point and sourced some inspiration from the other maubot plugins where necessary. here are my general tips for building a beeper-connected maubot
- set up your python editing environment so that it can read the maubot python package. this ended up being critical because the auto-complete suggestions were more helpful than the documentation in many cases
- I found reverse engineering most helpful in my case. IE: use beeper to send an iMessage with the format I’m aiming for (a photo with no text). then in beeper, right click the message → view source and try to find the API calls that seem like thye would produce that payload.
- when in doubt, read the docs here for the matrix python sdk
- here’s the source code that I ended up with to run my bot
Once I had everything working from the docker container running on my laptop, I just needed to get this hosted somewhere that was permanently online.
-
spin up a new ec2 instance on AWS - make sure to allow http and https connections in the settings when you are creating it
-
ssh
into it and install python, docker, and yarn- I don’t remember the exact commands here, but it was the expected dance with trial, error, and google search while blind-firing
sudo yum
commands from the hip
- I don’t remember the exact commands here, but it was the expected dance with trial, error, and google search while blind-firing
-
create a
maubot
directory on your ec2 box, and follow maubot’s docker steps, as well as steps 1-3 of “Production setup” to install themaubot-cli
-
expose the Maubot Manager web UI that your ec2 is hosting.
(there is almost certainly a more graceful way to do this using the
config.yaml
file, but the goal line was in sight, so here’s what I went with.)- signed up for an ngrok account and downloaded the linux installation on my laptop
- unzipped the file and scp’ed the binary into my ec2 instance
scp -i "path/to/ec2_keys.pem" ~/Downloads/ngrok [email protected]:~/
- authed with ngrok with the account I just signed up for
ngrok config add-authtoken myToken
- created a tunnel to port
29316
where my docker was running the Maubot Managerngrok http 29316
- copy and paste the https URL that ngrok generates (makes sure https not http) and append /_matrix/maubot to it in your laptop browser
- upload your plugin, create a client and an instance using your beeper credentials - just as before, and you’re in business! your maubot can send and receive messages on your behalf regardless of whether you’re online or not.