Skip to main content

user_context type

This reference documents the Slack types at the platform level. Their availability and structure may differ in each SDK

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_context will be passed from the trigger to the function input. If the workflow contains a step that alters the user_context value (like a message with a button), then the altered user_context value 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_context value (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.

PropertyTypeDescription
defaultThe type that is being described.An optional parameter default value.
descriptionstringAn optional parameter description.
examplesAn array of the type being described.An optional list of examples.
hintstringAn optional parameter hint.
titlestringAn optional parameter title.
typestringString that defines the parameter type.
idstringThe user_id of the person to which the user_context belongs.
secretstringA 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:

// ...
"input_parameters": {
"person_reporting_bug": {
"type": "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,
},
);