user_context type
Type: slack#/types/user_context
Using user_context in Workflow Builder
In Workflow Builder, this input type will not have a visible input field and cannot be set manually by a builder. Instead, the way the value is set is dependent on the situation:
-
If the workflow starts from an explicit user action (with a link trigger, for example), then the
user_contextwill be passed from the trigger to the function input. If the workflow contains a step that alters theuser_contextvalue (like a message with a button), then the altereduser_contextvalue is passed to the function input. -
If the workflow starts from something other than an explicit user action (from a scheduled trigger, for example), then the builder of the workflow must place a step that sets the
user_contextvalue (like a message with a button). This value will then be passed to the input of the function.
If a workflow step requires user_context and there is no way to ascertain the value within Workflow Builder, the workflow cannot be published.
| 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. |
id | string | The user_id of the person to which the user_context belongs. |
secret | string | A hash used internally by Slack to validate the authenticity of the id in the user_context. This can be safely ignored, since it's only used by us at Slack to avert malicious actors! |
Declare the user_context type:
- JSON manifest
- Deno Slack SDK
// ...
"input_parameters": {
"person_reporting_bug": {
"type": "slack#/types/user_context",
"description": "Which user?"
}
}
// ...
// ...
input_parameters: {
properties: {
person_reporting_bug: {
type: Schema.slack.types.user_context,
description: "Which user?",
},
},
},
// ...
User context example
In this example workflow, we use the Schema.slack.types.user_context type to report a bug in a system and to collect the reporter's information.
import { DefineWorkflow, Schema } from "deno-slack-sdk/mod.ts";
const ReportBugWorkflow = DefineWorkflow({
callback_id: "report_bug",
title: "Report a Bug",
description: "Report a bug",
input_parameters: {
properties: {
channel_id: {
type: Schema.slack.types.channel_id,
description: "Which channel?",
},
person_reporting_bug: {
type: Schema.slack.types.user_context,
description: "Which user?",
},
},
required: ["person_reporting_bug"],
},
});
import { CreateBugFunction } from "../functions/create_bug.ts";
ReportBugWorkflow.addStep(
CreateBugFunction,
{
title: "title",
summary: "summary",
urgency: "S0",
channel_id: ReportBugWorkflow.inputs.channel_id,
creator: ReportBugWorkflow.inputs.person_reporting_bug,
},
);