How to set up a delta-bot in 7 steps

Do you want to set up your own DeltaChat bot??? It is really easy, read on.

Requisites:

  • An email account for the bot.
  • GNU/Linux 64bit machine (can be installed in other systems but you will need to compile DeltaChat’s core yourself but that isn’t covered in this tutorial)
  • 500MB of RAM or more (a bot with few users use less than 100MB of RAM)
  • Python >=3.6

Steps:

  1. Declare bot address and password (Optional just to make this tutorial easier):
    $ ADDR='bot@example.com'
    $ PASSWORD='myPassword'
    
  2. Create and activate virtual environment (Optional but recommended):
    $ python3 -m venv ~/.venvs/`echo $ADDR|tr "@" "_"`
    $ source ~/.venvs/`echo $ADDR|tr "@" "_"`/bin/activate
    $ pip3 install -U pip wheel
    
  3. Install deltachat’s python bindings:
    $ pip3 install -U -i https://m.devpi.net/dc/master deltachat
    
  4. Install simplebot:
     $ git clone https://github.com/simplebot-inc/simplebot
     $ pip3 install ./simplebot
    
  5. Install some plugins:
     $ git clone https://github.com/simplebot-inc/simplebot_plugins
     $ python3 simplebot_plugins/scripts/install_plugin.py
    
  6. Configure bot:
     $ simplebot --basedir ~/bots/`echo $ADDR|tr "@" "_"` init $ADDR "$PASSWORD"
    
  7. Start the bot:
     $ simplebot --basedir ~/bots/`echo $ADDR|tr "@" "_"` serve
    

And that is all, now your have your very own delta-bot! go to your DeltaChat app and write a message: /help to your bot’s address to check it is working!

It is very cheap to run a bot, so you can repeat this steps in the same machine with another email account and have several bots, I recommend to have 250-500MB of RAM per bot if it will be a public bot.

4 Likes

:fireworks::sparkler::confetti_ball::tada: Thanks so much! :tada::confetti_ball::sparkler::fireworks:

1 Like

I have no idea what I’m doing wrong but I can’t run a simplebot on my machine. I’m using Ubuntu 20.04 and I wanted to test simplebot. All I get are the following error messages. When I configure bot (step 6):

“Traceback (most recent call last):
File “[…]/bin/simplebot”, line 8, in
sys.exit(main())
File “[…]/lib/python3.8/site-packages/deltabot/main.py”, line 24, in main
parser.main_run(bot=bot, args=args)
File “[…]/lib/python3.8/site-packages/deltabot/parser.py”, line 87, in main_run
res = args.subcommand_instance.run(bot=bot, args=args, out=out)
File “[…]/lib/python3.8/site-packages/deltabot/builtin/cmdline.py”, line 51, in run
success = bot.perform_configure_address(args.emailaddr, args.password)
File “[…]/lib/python3.8/site-packages/deltabot/bot.py”, line 160, in perform_configure_address
self.account.update_config(dict(
File “[…]/lib/python3.8/site-packages/deltachat/account.py”, line 155, in update_config
self.set_config(key, str(value))
File “[…]/lib/python3.8/site-packages/deltachat/account.py”, line 111, in set_config
self._check_config_key(name)
File “[…]/lib/python3.8/site-packages/deltachat/account.py”, line 78, in _check_config_key
raise KeyError(”{!r} not a valid config key, existing keys: {!r}".format(
KeyError: “‘bot’ not a valid config key, existing keys: [‘addr’, ‘mail_server’, ‘mail_user’, ‘mail_pw’, ‘mail_port’, ‘imap_certificate_checks’, ‘send_server’, ‘send_user’, ‘send_pw’, ‘send_port’, ‘smtp_certificate_checks’, ‘server_flags’, ‘imap_folder’, ‘displayname’, ‘selfstatus’, ‘selfavatar’, ‘bcc_self’, ‘e2ee_enabled’, ‘mdns_enabled’, ‘inbox_watch’, ‘sentbox_watch’, ‘mvbox_watch’, ‘mvbox_move’, ‘show_emails’, ‘media_quality’, ‘key_gen_type’, ‘delete_server_after’, ‘delete_device_after’, ‘save_mime_headers’, ‘configured_addr’, ‘configured_mail_server’, ‘configured_mail_user’, ‘configured_mail_pw’, ‘configured_mail_port’, ‘configured_mail_security’, ‘configured_imap_certificate_checks’, ‘configured_send_server’, ‘configured_send_user’, ‘configured_send_pw’, ‘configured_send_port’, ‘configured_smtp_certificate_checks’, ‘configured_server_flags’, ‘configured_send_security’, ‘configured_e2ee_enabled’, ‘configured_inbox_folder’, ‘configured_mvbox_folder’, ‘configured_sentbox_folder’, ‘configured’, ‘sys.version’, ‘sys.msgsize_max_recommended’, ‘sys.config_keys’, ‘notify_about_wrong_pw’, ‘basic_web_rtc_instance’]”

And later when I start the bot (step 7):

FAIL: account not configured: [full path]/account.db

Btw, I’m using a Mail-In-A-Box instance to run my email but I don’t think it matters here.

You are using an old core, change the dependency to use a core version >= 1.47

as @Simon said, you are using an old version of the deltachat package, run step 3 again, the ‘bot’ configuration was added recently to indicate the account is a bot (it might be used in the future to advertise the account as a bot and show nice “bot” indicators in the Delta Chat clients)

I will update simplebot package to state >=1.40.2 is requred

Just did that, but the error is still there. Perhaps the files up on https://m.devpi.net/dc/master are out-of-date?

I just configured a new bot some minutes ago without any issue, got deltachat-1.40.2 installed from https://m.devpi.net/dc/master,
this smells a lot to a weird issue that happened to me once, try this first:
pip install -U pip

then you can go with:
pip install --pre -U -i https://m.devpi.net/dc/master deltachat

ahhh maybe it is the --pre option!

Yup, that’s it. Now I managed to start the bot. Thank you!

1 Like

great! :tada:
btw, a bit late by now but: welcome to the forum!

Thanks again. Great to be here :vulcan_salute:t2: