expenses_pipeline/expenses-pipeline-p_13CN51K/fetch_message/entry.js
2026-03-31 23:45:36 +00:00

31 lines
No EOL
844 B
JavaScript

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,
};
}
});