Here is example code for e2ee-capable bot using the matrix-js-sdk library: https://gitlab.com/aleixq/matrix-js-sdk-bot-template
Reply on news.ycombinator.com