message_context type
This reference documents the Slack types at the platform level. Their availability and structure may differ in each SDK
Type: slack#/types/message_context
| 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. |
The message_context type is used in the ReplyInThread Slack function as the target message you want to reply to.
For example, let's say you have a workflow step that uses the SendMessage function. If you want to send a reply to that message in a follow-on step that calls the ReplyInThread function, pass the return value from the first step into the message_context parameter of ReplyInThread.
Here's a brief example:
- JSON manifest
- Deno Slack SDK
// ...
"message_context": {
"type": "slack#/types/message_context"
}
// ...
// Send a message to channel with ID C123456
const msgStep = GreetingWorkflow.addStep(Schema.slack.functions.SendMessage, {
channel_id: "C123456",
message: "This is a message to the channel.",
});
// Send a message as an in-thread reply to the above message by passing
// the outputs' message_context property
GreetingWorkflow.addStep(Schema.slack.functions.ReplyInThread, {
message_context: msgStep.outputs.message_context,
message: "This is a threaded reply to the above message.",
});
You can also construct and deconstruct the message_context property as you see fit in your app. Here is what comprises message_context:
| Property | Type | Description | Required |
|---|---|---|---|
message_ts | Schema.slack.types.message_ts | A Slack-specific hash/timestamp necessary for referencing events like messages in Slack. | Required |
channel_id | Schema.slack.types.channel_id | The ID of the channel where the message is posted. | Optional |
Any individual property on message_context could be referenced too. See the below example where we pass message_context.message_ts to the trigger_ts property:
//...
const message = CreateSurveyWorkflow.addStep(
Schema.slack.functions.ReplyInThread,
{
message_context: {
channel_id: CreateSurveyWorkflow.inputs.channel_id,
message_ts: CreateSurveyWorkflow.inputs.parent_ts,
},
message:
`Your feedback is requested – <${trigger.outputs.trigger_url}|survey now>!`,
},
);
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, //Here we reference message_ts from message_context
trigger_id: trigger.outputs.trigger_id,
survey_stage: "SURVEY",
});
//...