# Chat bridge

Want to learn how to create a chat bridge that links two applications together? Read this for more info

Ever wanted to use two chat applications at once but dont want to switch between the two constantly. There is a bot that can link the two services together so messages from one platform goes to the other and vice versa, This post will teach you how to create the bot yourself

### What is a chat bridge?

A chat bridge is a bot that can link two applications together such as telegram and discord, so when a message is sent in discord the bot sends the message in telegram and vise versa.

Chat bridges are useful because not everyone uses discord for whatever their reasons are, so this is why we have chat bridges.

There are a few chat bridge programs that I have seen one of them is matterbridge This is one of the biggest chat bridges I have seen, I have seen some programs that are only a bridge for two programs but matter bridge supports 13 programs now that’s a lot. These programs are IRC, XMPP, Gitter, Slack, Discord, Telegram, Hipchat, Rocket.chat, Matrix, Steam, Twitch, Ssh-chat, and lastly Xulip.

As I am writing this post I am trialing slack -> discord. What I am wanting to do is when a message is sent in my slack channel that message then gets posted in my discord server and if a message gets posted in discord it will send to slack.

I have just managed to get it working with just slack and discord lets do a quick tutorial on how to create this chat bridge.

Make sure you have go downloaded. You can download GO here you will then need to go to C:/ directory and create a new folder called chatbridge

Your next step is to open up a terminal and send the following command cd C:/chatbridge if there is an unknown error make sure you are using the correct directory. It should point to the folder you just created.

If it works fine then your next command you will need to send is go get github.com/42wim/matterbridge This will download the necessary files needed to create the chat bridge.

After the download is complete you will need to download mattermost by going to their Website

When you have downloaded matter most you will need to start creating your config files. So in your chatbridge folder create a new document called matterbridge.toml. In this post, we will be creating a discord to slack program. So in your matterbridge file, you will post the following

[discord.mydiscord]
Token="yyy"
Server="www"
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
IgnoreMessages="@everyone @here"

[slack.myslack]
Token="xxxx"
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
IgnoreMessages="@everyone @here"

[[gateway]]
name="gateway1"
enable=true

[[gateway.inout]]
account="discord.mydiscord"
channel="vvv"

[[gateway.inout]]
account="slack.myslack"
channel="zzz"


#### Here is some steps to get the config file working

You will need to replace yyy with a discord bot token, if you do not know how to create a bot and get the bot token you can read one of my previous posts Here When you have created the bot click bots and then click show token.

You will need to replace www with the server name, I have not actually tested if it has to be exactly the server name but to be safe I would just put in the name of the discord server.

After that, you will need to create a slack user token. First, make sure you are signed into slack and then click Here Scroll to the bottom and click create token

After that, you will then need to replace vvv with the name of the discord channel you want the bridge to be listening to Note that you do not add the # at the beginning so instead of doing channel=”#general”. You would do channel=”general”.

Your next step is to replace zzz with the channel on your slack server that you want to be listening to like discord make sure you do not add the # at the beginning of the channel name. Hit save and then let’s see if the bot will run….

Your last and final step is to open a terminal (Directed to the folder) and send the following command in the terminal matterbridge -conf matterbridge.toml Now if all works fine it should start listening to the server. To test it send a message in your channel on discord and then look at slack and there should be a new message.

They would look something like this

Now, that’s it, for now, I may make another post on how to make multiple bridges at the same time eg if you send a message on discord it sends to IRC and Slack. Depending on how popular this post is. Just remember the bridge only works when the bot is running