Slack App for cross posting messages to a different channel.
When someone asks a question in a channel, but that was not the right channel to ask, what do you do? Share the message to the right channel!
But now you have people replying to the original message and others replying to the shared message, no one knows what is going on! It's chaos!! Help! 😱
Don't worry, Cross Post is here to help you!
Now the message is shared to the correct channel and another message is sent to the original thread to indicate where the conversation should continue! Chaos no more! :smile:
- Click on
More Actions
on the message you want to share (you don't have to be the author) and select the channel you want to share
- Go to https://api.slack.com/apps/ and click on
Create App
and select your workspace - Add a name (
Cross Post
) and a description (Cross Post messages to another channel
) - Add an image (You can use the
crossroad.png
file from theimages
folder) and background color (#000000
) - Copy the value for
Signing Secret
and add it to the.env
file with keySLACK_SIGNING_SECRET
- Go to
OAuth & Permissions
- On the
Scopes
section, underBot Token Scopes
add the scopes:chat:write
,users:read
,chat:write.public
,channels:read
- On the
OAuth Tokens for Your Workspace
section, click onInstall to Workspace
- Copy the value of
Bot User OAuth Token
(it should start withxoxb-
) and add it to.env
file with keySLACK_BOT_TOKEN
- Go to the
Interactivity & Shortcuts
and turn it on - Add the URL for your App ending with
/slack/events
, e.g.https://example.ngrok.io/slack/events
- Click on
Create New Shortcut
and selectOn messages
- Add name (
Cross Post this message
) and description (Cross Post this message to another channel
) - Add the callback id
cross_post
- After some of these steps, you might get a warning that you will need to re-install your App, so go to
Install App
and click onReinstall to Workspace
- Click on the emoji on your input area and
Add Emoji
- Using the images from the
images
folder, addparrot-in
andparrot-out
to your Slack, using those exact names.
- Install node and ngrok
- Create a
.env
file and add the values forSLACK_SIGNING_SECRET
andSLACK_BOT_TOKEN
- Start your app with
npm start
- Start your tunnel with
ngrok http 6000
(or whatever port you used onindex.js
) - Update the URL on
Interactivity & Shortcuts
to point to the URL created on the previous step
(Note: the tunnel has a session, e.g. 2h, so make sure it's still up when you're testing)
You can host your App anywhere, on this example I hosted on GCP Cloud Functions.
- Create an Organization and a Project
- Inside your project click on
Create Function
- Add function name (
cross-post
) - On
Trigger
change toAllow unauthenticated invocations
(you can leave everything else as default or change as necessary) - Open
Runtime, build, ...
and click onAdd Variable
- Add
SLACK_SIGNING_SECRET
andSLACK_BOT_TOKEN
with the values you saved from previous steps - Click on Next
- Update the
package.json
andindex.js
files to the ones from thesrc
folder - On the
index.js
you can remove the part that is not necessary on Cloud Functions
(async () => {
await app.start(process.env.PORT || 6000);
console.log('Cross Post app is running!');
})();
- Add the
actions.js
andpayloads.js
files also from thesrc
folder - Make sure
Runtime
hasNode.js
selected - Change
Entry Point
toslack
- Click on Deploy 🎉
- If anything goes wrong you can check in the logs