From a5ac8fdbec4554d5b7ee1ab17e728b0f33f9a718 Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Thu, 29 Apr 2021 09:10:45 +0900 Subject: [PATCH] Fix #897 Add built-in fields to Context object type (#902) --- src/types/middleware.ts | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/types/middleware.ts b/src/types/middleware.ts index 23ad74b5b..6da930783 100644 --- a/src/types/middleware.ts +++ b/src/types/middleware.ts @@ -31,6 +31,40 @@ export interface Middleware { (args: Args & AllMiddlewareArgs): Promise; } -export interface Context extends StringIndexed {} +/** + * Context object, which provides contextual information associated with an incoming requests. + * You can set any other custom attributes in global middleware as long as the key does not conflict with others. + */ +export interface Context extends StringIndexed { + /** + * A bot token, which starts with `xoxb-`. + * This value can be used by `say` (preferred over userToken), + */ + botToken?: string; + /** + * A bot token, which starts with `xoxp-`. + * This value can be used by `say` (overridden by botToken), + */ + userToken?: string; + /** + * This app's bot ID in the installed workspace. + * This is required for `ignoreSelf` global middleware. + * see also: https://github.com/slackapi/bolt-js/issues/874 + */ + botId?: string; + /** + * This app's bot user ID in the installed workspace. + * This value is optional but allows `ignoreSelf` global middleware be more filter more than just message events. + */ + botUserId?: string; + /** + * Workspace ID. + */ + teamId?: string; + /** + * Enterprise Grid Organization ID. + */ + enterpriseId?: string; +} export type NextFn = () => Promise;