We had an old slackbot implementation, which synced discord messages to slack and vice versa. See https://github.com/cakephp/discord-slack-bridge
But this broke when Slack changed their API and discontinued the RTM API. Therefore, it was time to replace it.
The current solution is to use n8n, a powerful workflow automation tool which can do so much more than just bridging Discord and Slack.
It runs inside our apps.cakephp.org Server which hosts a bunch of dokku based apps.
The URL is https://automation.cakephp.org - for Backend access please ask a core member or @lordsimal
This uses the n8n built-in Slack trigger to listen for new messages in a specific Slack channel.
Each channel needs to be mapped individually to a Discord channel, since we
- don't want to sync every channel and
- some channels may have different names in Slack and Discord
N8N 2.0 now has a better way to debug workflow runs via looking at the "Executions" tab in the n8n UI.
This shows you directly which data gets sent for which trigger so you have a better overview of the data and can easily debug it.
- If a user edits or deletes a message in Slack, it is not synced to Discord.
- Reactions are not synced yet.
- Links sent from Slack to Discord appear as e.g.
https://book.cakephp.org/5/en/intro/conventions.html#database-conventions|https://book.cakephp.org/5/en/intro/conventions.html#database-conventions
This one was a bit more tricky, since Discord doesn't have a built-in trigger for new messages.
We needed to add a community node which adds a trigger for new messages in Discord channels.
This new bot also needed access to the Gateway Intents API, which was not present in the old bot we had till now.
Therefore, a new bot was created and was added to the CakePHP Discord server - very creatively named "CakePHP-Slack-Bot"
With that community node installed and the new bot added to the Discord server, we were now able to add a trigger for new messages in Discord channels.
- If a user edits or deletes a message in Discord, it is not synced to Slack.
- Reactions are not synced yet.
At first there was a problem with the community node not being persisted in the Dokku app. After a rebuild, the community node was not available anymore.
Fortunately, @d1ceward - who provided the initial Dokku setup - found a solution to this problem. d1ceward-on-dokku#4
dokku storage:ensure-directory automation --chown false
chown 1000:1000 /var/lib/dokku/data/storage/automation
dokku storage:mount automation /var/lib/dokku/data/storage/automation:/home/node/.n8nWith that, the community node is now persisted across rebuilds and restarts.
But I am not sure how to update community nodes yet...
There are 2 things that need to be done:
- Update the runner on the apps.cakephp.org Server via
dokku git:from-image automation-runners n8nio/runners:2.18.0 - Update the Dockerfile
N8N_VERSIONArg to use the same version and push the commit to trigger the deploy