-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Question
What I want to do is get any images from the exact message that my bot was tagged in. I have this trigger:
import type { Trigger } from "deno-slack-sdk/types.ts";
import { TriggerContextData, TriggerTypes, TriggerEventTypes } from "deno-slack-api/mod.ts";
import { TagCapnWorkflow } from "../workflows/RespondToTag.ts";
const trigger: Trigger = {
type: TriggerTypes.Event,
name: "Ask Capn",
description: "use @capn to tag Capn in a channel message",
workflow: `#/workflows/${TagCapnWorkflow.id}`,
event: {
event_type: TriggerEventTypes.AppMentioned,
all_resources: true,
},
inputs: {
user_id: {
value: TriggerContextData.Event.MessagePosted.user_id,
},
text: {
value: TriggerContextData.Event.MessagePosted.text,
},
channel_id: {
value: TriggerContextData.Event.MessagePosted.channel_id,
},
message_ts: {
// In the case this is a threaded message, this property becomes the message_ts of the parent message.
// Thus, if we are were tagged in a thread, this is the ts of the original message, not where we were tagged.
// TODO: should also pass in TriggerContextData.Event.MessagePosted.thread_ts,
// but this is sometimes null and therefore causes schema validation errors???
value: TriggerContextData.Event.MessagePosted.message_ts,
},
thread_ts: {
value: TriggerContextData.Event.MessagePosted.thread_ts,
},
},
};
export default trigger;From reading the docs (well, intellisense on TriggerContextData.Event.MessagePosted.thread_ts) l, my expectation was
- if the bot is tagged in the a thread, then
- message_ts is the top-level message
- thread_ts is the specific message that the bot was tagged in. This is the mesage I want to look for files in.
- if the bot is tagged in top-level of the channel, then
- message_ts is a value (and is the message I want to look for files in)
- thread_ts is NULL.
OK, so then I have this workflow:
import { DefineWorkflow, Schema } from "deno-slack-sdk/mod.ts";
import { RespondToCapnTagFunction } from "../functions/respond_to_tag_capn/definition.ts";
export const TagCapnWorkflow = DefineWorkflow({
callback_id: "tag_capn",
title: "Tag Capn",
description:
"use @capn to tag Capn in a channel message",
input_parameters: {
properties: {
user_id: {
type: Schema.slack.types.user_id,
description: "The ID of the user who tagged Capn",
},
channel_id: {
type: Schema.slack.types.channel_id,
description: "The ID of the channel where Capn was tagged",
},
text: {
type: Schema.types.string,
description: "The text of the message where Capn was tagged",
},
message_ts: {
type: Schema.slack.types.message_ts,
description: "The timestamp of the message where Capn was tagged",
},
thread_ts: {
type: Schema.slack.types.message_ts,
description: "The timestamp of the thread where Capn was tagged",
}
},
required: ["user_id", "channel_id", "text", "message_ts"],
},
});
TagCapnWorkflow.addStep(RespondToCapnTagFunction, {
text: TagCapnWorkflow.inputs.text,
user_id: TagCapnWorkflow.inputs.user_id,
channel_id: TagCapnWorkflow.inputs.channel_id,
message_ts: TagCapnWorkflow.inputs.message_ts,
thread_ts: TagCapnWorkflow.inputs.thread_ts,
});But, when I tag the bot in either the top level of a channel, OR in a thread, I get this error:
2025-10-23 14:03:14 [error] [Wf09MXNHK1K5] (Trace=Tr09NDTDF28L) Trigger for workflow 'Tag Capn' failed: parameter_validation_failed
2025-10-23 14:03:14 [error] [Wf09MXNHK1K5] (Trace=Tr09NDTDF28L) - Null value for non-nullable parameter `thread_ts`
Can you help me understand this? Can you give me a solution to my goal?
Environment
Paste the output of cat import_map.json | grep deno-slack
NA
Paste the output of deno --version
deno 2.3.3 (stable, release, aarch64-apple-darwin)
v8 13.7.152.6-rusty
typescript 5.8.3
Paste the output of sw_vers && uname -v on macOS/Linux or ver on Windows OS
ProductName: macOS
ProductVersion: 15.6.1
BuildVersion: 24G90
Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000
Requirements
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.