import { WebClient } from 'https://deno.land/x/slack_web_api@6.7.2/mod.js' const slackBotToken = Deno.env.get('SLACK_TOKEN') ?? '' const botClient = new WebClient(slackBotToken) console.log(`Slack URL verification function up and running!`) Deno.serve(async (req) => { try { const { token, challenge, type, event } = await req.json() if (type == 'url_verification') { return new Response(JSON.stringify({ challenge }), { headers: { 'Content-Type': 'application/json' }, status: 200, }) } else if (event.type == 'app_mention') { const { user, text, channel, ts } = event // Here you should process the text received and return a response: const response = await botClient.chat.postMessage({ channel: channel, text: `Hello <@${user}>!`, thread_ts: ts, }) return new Response('ok', { status: 200 }) } } catch (error) { return new Response(JSON.stringify({ error: error.message }), { headers: { 'Content-Type': 'application/json' }, status: 500, }) } })