initial commit

This commit is contained in:
pdgit 2026-03-31 23:45:36 +00:00
commit a9fe8d18fb
8 changed files with 204 additions and 0 deletions

1
README.md Normal file
View file

@ -0,0 +1 @@
Project repo_7kT73R

View file

@ -0,0 +1,5 @@
# DO NOT EDIT THIS FILE
---
schema: workflow.state/2022.04
id: p_13CN51K

View file

@ -0,0 +1,31 @@
import { axios } from "@pipedream/platform";
export default defineComponent({
props: {
slack: {
type: "app",
app: "slack_bot",
}
},
async run({ steps, $ }) {
console.log("Auth:", JSON.stringify(this.slack.$auth)); // ← moved here
const response = await axios($, {
method: "GET",
url: "https://slack.com/api/conversations.history",
headers: {
Authorization: `Bearer ${this.slack.$auth.bot_token}`,
},
params: {
channel: steps.route_check.$return_value.fromChannel,
latest: steps.route_check.$return_value.messageTs,
limit: 1,
inclusive: true,
},
});
console.log("Response:", JSON.stringify(response));
if (!response.ok) throw new Error(response.error);
return {
text: response.messages[0].text,
};
}
});

View file

@ -0,0 +1,26 @@
import { axios } from "@pipedream/platform";
export default defineComponent({
props: {
slack: {
type: "app",
app: "slack_bot",
}
},
async run({ steps, $ }) {
const response = await axios($, {
method: "GET",
url: "https://slack.com/api/chat.getPermalink",
headers: {
Authorization: `Bearer ${this.slack.$auth.bot_token}`,
},
params: {
channel: steps.route_check.$return_value.fromChannel,
message_ts: steps.route_check.$return_value.messageTs,
},
});
if (!response.ok) throw new Error(response.error);
return {
permalink: response.permalink,
};
}
});

View file

@ -0,0 +1,47 @@
import { axios } from "@pipedream/platform";
export default defineComponent({
props: {
slack: {
type: "app",
app: "slack_bot",
}
},
async run({ steps, $ }) {
const { toChannel, label } = steps.route_check.$return_value;
const { permalink } = steps.get_permalink.$return_value;
// Strip old React instruction from copied text
let text = steps.fetch_message.$return_value.text;
text = text.replace(/_React_ :white_check_mark: _to advance to \w+_/g, '').trim();
// Determine next stage label for the React instruction
const nextStageMap = {
'C0APLSGABAB': 'Authorized',
'C0AQ09CDJH4': 'Matched',
'C0APYUM1JFP': null, // Final stage — no next instruction
};
const nextLabel = nextStageMap[toChannel];
const reactLine = nextLabel
? `\n\n_React_ :white_check_mark: _to advance to ${nextLabel}_`
: '';
const permalinkLine = toChannel === 'C0APLSGABAB'
? `\n\n📎 *Original Submission:* <${permalink}|View Original Message>`
: '';
const fullText = `${text}${permalinkLine}${reactLine}`;
const response = await axios($, {
method: "POST",
url: "https://slack.com/api/chat.postMessage",
headers: {
Authorization: `Bearer ${this.slack.$auth.bot_token}`,
"Content-Type": "application/json",
},
data: {
channel: toChannel,
text: fullText,
mrkdwn: true,
unfurl_links: false,
unfurl_media: false,
},
});
if (!response.ok) throw new Error(response.error);
return { messageTs: response.ts };
}
});

View file

@ -0,0 +1,27 @@
import { axios } from "@pipedream/platform";
export default defineComponent({
props: {
slack: {
type: "app",
app: "slack_bot",
}
},
async run({ steps, $ }) {
const { fromChannel, messageTs, label } = steps.route_check.$return_value;
const response = await axios($, {
method: "POST",
url: "https://slack.com/api/chat.postMessage",
headers: {
Authorization: `Bearer ${this.slack.$auth.bot_token}`,
"Content-Type": "application/json",
},
data: {
channel: fromChannel,
thread_ts: messageTs,
text: `➡️ Advanced to ${label}`,
},
});
if (!response.ok) throw new Error(response.error);
return { success: true };
}
});

View file

@ -0,0 +1,32 @@
export default defineComponent({
async run({ steps }) {
const reaction = steps.trigger.event.reaction;
const fromChannel = steps.trigger.event.item.channel;
const messageTs = steps.trigger.event.item.ts;
// Only proceed for ✅ reactions
if (reaction !== 'white_check_mark') {
return $end('Not a white_check_mark reaction — skipping');
}
// Map source channel to destination channel and label
const channelMap = {
'C0AQ2AWLNEN': { next: 'C0APLSGABAB', label: 'Processed' },
'C0APLSGABAB': { next: 'C0AQ09CDJH4', label: 'Authorized' },
'C0AQ09CDJH4': { next: 'C0APYUM1JFP', label: 'Matched' },
};
const route = channelMap[fromChannel];
if (!route) {
return $end('Reaction not in an expense channel — skipping');
}
return {
fromChannel,
toChannel: route.next,
label: route.label,
messageTs,
};
}
});

View file

@ -0,0 +1,35 @@
schema: workflow/2022.04
name: Expenses Pipeline
settings:
error_notification: true
triggers:
- id: dc_DvudRW4
steps:
- namespace: route_check
runtime: nodejs20.x
uses: "./route_check/entry.js"
- namespace: fetch_message
runtime: nodejs20.x
uses: "./fetch_message/entry.js"
props:
slack:
authProvisionId: apn_86hW0ZZ
- namespace: get_permalink
runtime: nodejs20.x
uses: "./get_permalink/entry.js"
props:
slack:
authProvisionId: apn_86hW0ZZ
- namespace: post_to_next_channel
runtime: nodejs20.x
uses: "./post_to_next_channel/entry.js"
props:
slack:
authProvisionId: apn_86hW0ZZ
- namespace: reply_on_original
runtime: nodejs20.x
uses: "./reply_on_original/entry.js"
props:
slack:
authProvisionId: apn_86hW0ZZ