Class: TeamsPlugin
AppKit plugin that configures the Adaptive Card builder used by the
create_teams_card tool, and exposes card building as an AppKit agent tool.
Example
Section titled “Example”import { createApp, server } from "@databricks/appkit";import { plugin as teamsPlugin } from "@dbx-tools/teams";
await createApp({ plugins: [ server(), teamsPlugin.teams({ webhookUrl: process.env.TEAMS_WEBHOOK_URL }), ],});Extends
Section titled “Extends”Plugin<TeamsPluginConfig>
Implements
Section titled “Implements”ToolProvider
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new TeamsPlugin(
config):TeamsPlugin
Parameters
Section titled “Parameters”config
Section titled “config”Returns
Section titled “Returns”TeamsPlugin
Inherited from
Section titled “Inherited from”Plugin<TeamsPluginConfig>.constructor
Properties
Section titled “Properties”
protectedapp:AppManager
Inherited from
Section titled “Inherited from”Plugin.app
protectedcache:CacheManager
Inherited from
Section titled “Inherited from”Plugin.cache
config
Section titled “config”
protectedconfig:TeamsPluginConfig
Inherited from
Section titled “Inherited from”Plugin.config
context?
Section titled “context?”
protectedoptionalcontext?:PluginContext
Inherited from
Section titled “Inherited from”Plugin.context
devFileReader
Section titled “devFileReader”
protecteddevFileReader:DevFileReader
Inherited from
Section titled “Inherited from”Plugin.devFileReader
isReady
Section titled “isReady”
protectedisReady:boolean
Inherited from
Section titled “Inherited from”Plugin.isReady
name:
string
Plugin name identifier.
Inherited from
Section titled “Inherited from”Plugin.name
streamManager
Section titled “streamManager”
protectedstreamManager:StreamManager
Inherited from
Section titled “Inherited from”Plugin.streamManager
telemetry
Section titled “telemetry”
protectedtelemetry:ITelemetry
Inherited from
Section titled “Inherited from”Plugin.telemetry
manifest
Section titled “manifest”
staticmanifest:object
config
Section titled “config”config:
object
config.schema
Section titled “config.schema”schema:
JSONSchema7=TEAMS_CONFIG_SCHEMA
description
Section titled “description”description:
string
displayName
Section titled “displayName”displayName:
string="Teams"
name:
"teams"="teams"
resources
Section titled “resources”resources:
object
resources.optional
Section titled “resources.optional”optional:
never[] =[]
resources.required
Section titled “resources.required”required:
never[] =[]
stability
Section titled “stability”stability:
"beta"="beta"
staticphase:PluginPhase
Plugin initialization phase.
- ‘core’: Initialized first (e.g., config plugins)
- ‘normal’: Initialized second (most plugins)
- ‘deferred’: Initialized last (e.g., server plugin)
Inherited from
Section titled “Inherited from”Plugin.phase
Methods
Section titled “Methods”abortActiveOperations()
Section titled “abortActiveOperations()”abortActiveOperations():
void
Cancel in-flight work (abort signals, SSE streams). Runs in the first
phase of graceful shutdown, BEFORE any plugin’s shutdown() hook —
so it must not tear down shared resources (e.g. connection pools)
that other plugins’ hooks may still need. Put teardown in shutdown().
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Plugin.abortActiveOperations
asUser()
Section titled “asUser()”asUser(
req):this
Execute operations using the user’s identity from the request. Returns a proxy of this plugin where all method calls execute with the user’s Databricks credentials instead of the service principal.
Parameters
Section titled “Parameters”Request
The Express request containing the user token in headers
Returns
Section titled “Returns”this
A proxied plugin instance that executes as the user
Throws
Section titled “Throws”AuthenticationError if user token is not available in request headers (production only).
In development mode (NODE_ENV=development), skips user impersonation instead of throwing.
Inherited from
Section titled “Inherited from”Plugin.asUser
attachContext()
Section titled “attachContext()”attachContext(
deps?):void
Binds runtime dependencies (telemetry provider, cache, plugin context) to
this plugin. Called by AppKit._createApp after construction and before
setup(). Idempotent: safe to call if the constructor already bound them
eagerly. Kept separate so factories can eagerly construct plugin instances
without running this before TelemetryManager.initialize() /
CacheManager.getInstance() have run.
Parameters
Section titled “Parameters”context?
Section titled “context?”unknown
telemetryConfig?
Section titled “telemetryConfig?”TelemetryOptions
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Plugin.attachContext
clientConfig()
Section titled “clientConfig()”clientConfig():
Record<string,unknown>
Returns startup config to expose to the client. Override this to surface server-side values that are safe to publish to the frontend, such as feature flags, resource IDs, or other app boot settings.
This runs once when the server starts, so it should not depend on request-scoped or user-specific state.
String values that match non-public environment variables are redacted
unless you intentionally expose them via a matching PUBLIC_APPKIT_ env var.
Values must be JSON-serializable plain data (no functions, Dates, classes, Maps, Sets, BigInts, or circular references). By default returns an empty object (plugin contributes nothing to client config).
On the client, read the config with the usePluginClientConfig hook
(React) or the getPluginClientConfig function (vanilla JS), both
from @databricks/appkit-ui.
Returns
Section titled “Returns”Record<string, unknown>
Example
Section titled “Example”// Server — plugin definitionclass MyPlugin extends Plugin<MyConfig> { clientConfig() { return { warehouseId: this.config.warehouseId, features: { darkMode: true }, }; }}
// Client — React componentimport { usePluginClientConfig } from "@databricks/appkit-ui/react";
interface MyPluginConfig { warehouseId: string; features: { darkMode: boolean } }
const config = usePluginClientConfig<MyPluginConfig>("myPlugin");config.warehouseId; // "abc-123"
// Client — vanilla JSimport { getPluginClientConfig } from "@databricks/appkit-ui/js";
const config = getPluginClientConfig<MyPluginConfig>("myPlugin");Inherited from
Section titled “Inherited from”Plugin.clientConfig
execute()
Section titled “execute()”
protectedexecute<T>(fn,options,userKey?):Promise<ExecutionResult<T>>
Execute a function with the plugin’s interceptor chain.
Returns an ExecutionResult discriminated union:
{ ok: true, data: T }on success{ ok: false, status: number, message: string }on failure
Errors are never thrown — the method is production-safe.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”(signal?) => Promise<T>
options
Section titled “options”PluginExecutionSettings
userKey?
Section titled “userKey?”string
Returns
Section titled “Returns”Promise<ExecutionResult<T>>
Inherited from
Section titled “Inherited from”Plugin.execute
executeAgentTool()
Section titled “executeAgentTool()”executeAgentTool(
name,args,signal?):Promise<unknown>
AppKit ToolProvider: run one tool call. Arguments are validated against
the tool’s schema first, and a validation failure comes back as an
LLM-friendly string so the model can correct itself on the next turn.
Parameters
Section titled “Parameters”string
unknown
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<unknown>
Implementation of
Section titled “Implementation of”ToolProvider.executeAgentTool
executeStream()
Section titled “executeStream()”
protectedexecuteStream<T>(res,fn,options,userKey?):Promise<void>
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”IAppResponse
StreamExecuteHandler<T>
options
Section titled “options”StreamExecutionSettings
userKey?
Section titled “userKey?”string
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”Plugin.executeStream
exports()
Section titled “exports()”exports():
object
Returns the public exports for this plugin. Override this to define a custom public API. By default, returns an empty object.
The returned object becomes the plugin’s public API on the AppKit instance
(e.g. appkit.myPlugin.method()). AppKit automatically binds method context
and adds asUser(req) for user-scoped execution.
Returns
Section titled “Returns”buildCard
Section titled “buildCard”buildCard: (
spec,signal?) =>Promise<{card: {$schema:string;actions?:Record<string,unknown>[];body:Record<string,unknown>[];type:"AdaptiveCard";version:string; };title:string; }>
Compile a card spec into an Adaptive Card document. For agent-driven builds use teamsCardTool instead.
Parameters
Section titled “Parameters”actions?
Section titled “actions?”object[] = ...
facts?
Section titled “facts?”object[] = ...
subtitle?
Section titled “subtitle?”string = ...
string = ...
string = ...
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<{ card: { $schema: string; actions?: Record<string, unknown>[]; body: Record<string, unknown>[]; type: "AdaptiveCard"; version: string; }; title: string; }>
postCard
Section titled “postCard”postCard: (
cardDocument,signal?) =>Promise<void>
Post a compiled card to the configured Teams incoming webhook. Throws when no webhook is configured.
Parameters
Section titled “Parameters”cardDocument
Section titled “cardDocument”$schema
Section titled “$schema”string = ...
actions?
Section titled “actions?”Record<string, unknown>[] = ...
Record<string, unknown>[] = ...
"AdaptiveCard" = ...
version
Section titled “version”string = ...
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”class MyPlugin extends Plugin { private getData() { return []; }
exports() { return { getData: this.getData }; }}
// After registration:const appkit = await createApp({ plugins: [myPlugin()] });appkit.myPlugin.getData();Overrides
Section titled “Overrides”Plugin.exports
getAgentTools()
Section titled “getAgentTools()”getAgentTools():
AgentToolDefinition[]
AppKit ToolProvider: the tool definitions offered to an agent.
Returns
Section titled “Returns”AgentToolDefinition[]
Implementation of
Section titled “Implementation of”ToolProvider.getAgentTools
getEndpoints()
Section titled “getEndpoints()”getEndpoints():
PluginEndpointMap
Returns
Section titled “Returns”PluginEndpointMap
Inherited from
Section titled “Inherited from”Plugin.getEndpoints
getSkipBodyParsingPaths()
Section titled “getSkipBodyParsingPaths()”getSkipBodyParsingPaths():
ReadonlySet<string>
Returns
Section titled “Returns”ReadonlySet<string>
Inherited from
Section titled “Inherited from”Plugin.getSkipBodyParsingPaths
injectRoutes()
Section titled “injectRoutes()”injectRoutes(
router):void
Mount the card-building and card-posting routes under the plugin base
path (/api/teams). POST /card is what the dev display page calls to
preview a card live; POST /post pushes a compiled card to the configured
Teams incoming webhook.
Neither route is wrapped in asUser(req): compiling a card is a pure
transform of the request body and posting goes to a preconfigured webhook,
so neither reads workspace data on the caller’s behalf and neither needs an
OBO token. Wrapping them would make the routes throw
AuthenticationError whenever the user-token header is absent (a local
curl, a health probe), which - since AppKit does not catch a rejection
raised inside the handler - takes the process down rather than answering
401.
Parameters
Section titled “Parameters”router
Section titled “router”Router
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”Plugin.injectRoutes
registerEndpoint()
Section titled “registerEndpoint()”
protectedregisterEndpoint(name,path):void
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Plugin.registerEndpoint
resolveUserId()
Section titled “resolveUserId()”
protectedresolveUserId(req):string
Resolve the effective user ID from a request.
Returns the x-forwarded-user header when present. In development mode
(NODE_ENV=development) falls back to the current context user ID so
that callers outside an active runInUserContext scope still get a
consistent value.
Parameters
Section titled “Parameters”Request
Returns
Section titled “Returns”string
Throws
Section titled “Throws”AuthenticationError in production when no user header is present.
Inherited from
Section titled “Inherited from”Plugin.resolveUserId
route()
Section titled “route()”
protectedroute<_TResponse>(router,config):void
Type Parameters
Section titled “Type Parameters”_TResponse
Section titled “_TResponse”_TResponse
Parameters
Section titled “Parameters”router
Section titled “router”Router
config
Section titled “config”RouteConfig
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Plugin.route
setup()
Section titled “setup()”setup():
Promise<void>
Prime the shared runtime from this plugin’s config (over env), route the tool’s builds through this plugin’s interceptor chain, and log the effective config so the resolved card version and whether a webhook is wired up are obvious at boot.
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”Plugin.setup
shutdown()
Section titled “shutdown()”shutdown():
Promise<void>
Drop the shared runtime. Idempotent.
Returns
Section titled “Returns”Promise<void>