Skip to content

Instantly share code, notes, and snippets.

@tim775
Created December 31, 2025 21:10
Show Gist options
  • Select an option

  • Save tim775/bbcf473460fbe786e927d8d961b23988 to your computer and use it in GitHub Desktop.

Select an option

Save tim775/bbcf473460fbe786e927d8d961b23988 to your computer and use it in GitHub Desktop.
Veija slack app rule
// Veija slack app rule
// This opens slack channel or message links in the slack app.
//
// 1. Log in to your slack workspace in a browser and copy
// your team id (TXXXXXXXXX) from the url: e.g. "T012345679A"
// from "https://app.slack.com/client/T012345679A/C0123456789"
// 2. Create a new veija rule that matches url domain and
// subdomain on <yourslackteam>.slack.com
// 3. Enable 'Transform URL' for the rule, Edit script and paste
// this code. Make sure to replace the value of TEAM_ID with
// your actual id.
const TEAM_ID = "T0000000000";
const m = $.url.pathname.match(/\/archives\/(C\w+)(?:\/p(\d+))?/);
if (m) {
const channelId = m[1];
const messageTs = m[2];
let url = `slack://channel?team=${TEAM_ID}&id=${channelId}`;
// add message timestamp if present
if (messageTs) {
url += `&message=${messageTs}`;
}
// parse thread_ts from query params if present
const queryParams = new URLSearchParams($.url.search);
const threadTs = queryParams.get('thread_ts');
if (threadTs) {
url += `&thread_ts=${threadTs}`;
}
$.url = url;
}
@travis-wellthy

travis-wellthy commented Mar 4, 2026

Copy link
Copy Markdown

Line 15:

const m = $.url.pathname.match(//archives/(C\w+)(?:/p(\d+))?/);

Will not work on DMs (which start with a D not a C)

But if you change it to:

const m = $.url.pathname.match(//archives/([CD]\w+)(?:/p(\d+))?/);

Then it will work on DMs too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment