message_ts type
This reference documents the Slack types at the platform level. Their availability and structure may differ in each SDK
Type: slack#/types/message_ts
| Property | Type | Description |
|---|---|---|
default | The type that is being described. | An optional parameter default value. |
description | string | An optional parameter description. |
examples | An array of the type being described. | An optional list of examples. |
hint | string | An optional parameter hint. |
title | string | An optional parameter title. |
type | string | String that defines the parameter type. |
Declare a message_ts type:
- JSON manifest
- Deno Slack SDK
// ...
"input_parameters": {
"message_ts": {
"type": "slack#/types/message_ts",
"description": "The ts value of a message"
}
}
// ...
//...
input_parameters: {
properties: {
message_ts : {
type: Schema.slack.types.message_ts,
description: "The ts value of a message"
},
},
},
//...
Message Timestamp example
In this example workflow from the Simple Survey sample app, a message_ts is used as an input parameter in two functions.
import { DefineWorkflow, Schema } from "deno-slack-sdk/mod.ts";
import { CreateGoogleSheetFunctionDefinition } from "../functions/create_google_sheet.ts";
import { CreateTriggerFunctionDefinition } from "../functions/create_survey_trigger.ts";
import { SaveSurveyFunctionDefinition } from "../functions/save_survey.ts";
import { RemoveThreadTriggerFunctionDefinition } from "../functions/remove_thread_trigger.ts";
const CreateSurveyWorkflow = DefineWorkflow({
callback_id: "create_survey",
title: "Create a survey",
description: "Add a request for feedback to a message",
input_parameters: {
properties: {
channel_id: {
type: Schema.slack.types.channel_id,
description: "The channel containing the reacted message",
},
parent_ts: {
type: Schema.types.string,
description: "Message timestamp of the reacted message",
},
parent_url: {
type: Schema.types.string,
description: "Permalink to the reacted message",
},
reactor_id: {
type: Schema.slack.types.user_id,
description: "User that added the reacji",
},
},
required: ["channel_id", "parent_ts", "parent_url", "reactor_id"],
},
});
// Step 1: Create a new Google spreadsheet
const sheet = CreateSurveyWorkflow.addStep(
CreateGoogleSheetFunctionDefinition,
{
google_access_token_id: {},
title: CreateSurveyWorkflow.inputs.parent_ts,
},
);
// Step 2: Create a link trigger for the survey
const trigger = CreateSurveyWorkflow.addStep(CreateTriggerFunctionDefinition, {
google_spreadsheet_id: sheet.outputs.google_spreadsheet_id,
reactor_access_token_id: sheet.outputs.reactor_access_token_id,
});
// Step 3: Delete the prompt message and metadata
CreateSurveyWorkflow.addStep(RemoveThreadTriggerFunctionDefinition, {
channel_id: CreateSurveyWorkflow.inputs.channel_id,
parent_ts: CreateSurveyWorkflow.inputs.parent_ts,
reactor_id: CreateSurveyWorkflow.inputs.reactor_id,
});
// Step 4: Notify the reactor of the survey spreadsheet
CreateSurveyWorkflow.addStep(Schema.slack.functions.SendDm, {
user_id: CreateSurveyWorkflow.inputs.reactor_id,
message:
`Feedback for <${CreateSurveyWorkflow.inputs.parent_url}|this message> is being <${sheet.outputs.google_spreadsheet_url}|collected here>!`,
});
// Step 5: Send the survey into the reacted thread
const message = CreateSurveyWorkflow.addStep(
Schema.slack.functions.ReplyInThread,
{
message_context: {
channel_id: CreateSurveyWorkflow.inputs.channel_id,
message_ts: CreateSurveyWorkflow.inputs.parent_ts, //used here as part of the message_context object
},
message:
`Your feedback is requested – <${trigger.outputs.trigger_url}|survey now>!`,
},
);
// Step 6: Store new survey metadata
CreateSurveyWorkflow.addStep(SaveSurveyFunctionDefinition, {
channel_id: CreateSurveyWorkflow.inputs.channel_id,
parent_ts: CreateSurveyWorkflow.inputs.parent_ts,
reactor_id: CreateSurveyWorkflow.inputs.reactor_id,
trigger_ts: message.outputs.message_context.message_ts, //Referenced here individually
trigger_id: trigger.outputs.trigger_id,
survey_stage: "SURVEY",
});
export default CreateSurveyWorkflow;