import { WebClient } from 'https://deno.land/x/[email protected]/mod.ts';
import * as wmill from 'https://deno.land/x/[email protected]/mod.ts';
type Slack = {
token: string;
};
export async function main(
response_url: string,
text: string,
channel_id?: string,
command?: string
) {
if (command === "@mention") {
// @mention - use Slack API
const slack = await wmill.getResource<Slack>('f/slack_bot/bot_token');
const web = new WebClient(slack.token);
await web.chat.postMessage({
channel: channel_id,
text: `Echo: ${text}`
});
} else {
// Slash command - use response_url
await fetch(response_url, {
method: 'POST',
body: JSON.stringify({ text: `Echo: ${text}` })
});
}
} Submitted by alex308 29 days ago
import { WebClient } from "https://deno.land/x/[email protected]/mod.ts";
import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
type Slack = {
token: string;
};
export async function main(
response_url: string,
text: string,
slack: Slack,
channel_id?: string,
command?: string
) {
const username = await Deno.env.get("WM_USERNAME");
console.log(`user = ${username}`);
const responseText = `ROGER ${text}`;
// Check if triggered by @mention or /windmill command
if (command === "@mention") {
// For @mentions, use Slack API to respond
const web = new WebClient(slack.token);
await web.chat.postMessage({
channel: channel_id,
text: responseText,
});
} else {
// For slash commands, use response_url
await fetch(response_url, {
method: "POST",
body: JSON.stringify({ text: responseText }),
});
}
}
Submitted by hugo697 30 days ago
export async function main(response_url: string, text: string) {
const x = await fetch(response_url, {
method: "POST",
body: JSON.stringify({ text: `ROGER ${text}` }),
});
const username = await Deno.env.get("WM_USERNAME");
console.log(`user = ${username}`);
}
Submitted by hugo697 191 days ago
export async function main(response_url: string, text: string) {
const x = await fetch(response_url, {
method: "POST",
body: JSON.stringify({ text: `ROGER ${text}` }),
});
const username = await Deno.env.get("WM_USERNAME");
console.log(`user = ${username}`);
}
Submitted by hugo697 205 days ago
export async function main(response_url: string, text: string) {
const x = await fetch(response_url, {
method: "POST",
body: JSON.stringify({ text: `ROGER ${text}` }),
});
const username = await Deno.env.get("WM_USERNAME");
console.log(`user = ${username}`);
}
Submitted by hugo697 766 days ago
export async function main(
response_url: string,
text: string,
) {
const x = await fetch(response_url, {
method: 'POST',
body: JSON.stringify({ text: `ROGER ${text}` }),
});
const username = await Deno.env.get('WM_USERNAME')
console.log(`user = ${username}`) Submitted by admin 768 days ago
export async function main(response_url: string, text: string) {
const x = await fetch(response_url, {
method: "POST",
body: JSON.stringify({ text: `ROGER ${text}` }),
});
const username = await Deno.env.get("WM_USERNAME");
console.log(`user = ${username}`);
}
Submitted by hugo697 781 days ago
export async function main(
response_url: string,
text: string,
) {
const x = await fetch(response_url, {
method: 'POST',
body: JSON.stringify({ text: `ROGER ${text}` }),
});
const username = await Deno.env.get('WM_USERNAME')
console.log(`user = ${username}`) Submitted by henri186 855 days ago