Skip to content

Make adapter configs accept explicit config but default to env vars (not require them) #165

@vercel

Description

@vercel

Summary

Adapter config interfaces currently require certain fields to be explicitly provided. The factory functions (create*Adapter) do auto-resolve from env vars, but the underlying config types (SlackAdapterConfig, DiscordAdapterConfig, TeamsAdapterConfig, etc.) mark these fields as required — meaning consumers who construct adapters directly must pass them explicitly even when env vars would suffice.

The request is to make the config types more ergonomic: accept config overrides when provided, but automatically fall back to env vars when fields are omitted — i.e., make the config fields optional at the type level.

Current Behavior

Several adapter configs require fields explicitly:

  • SlackAdapterConfigsigningSecret: string and logger: Logger are required
  • DiscordAdapterConfigbotToken, publicKey, and applicationId are all required strings
  • TeamsAdapterConfigappId, appPassword, and logger are required
  • GoogleChatAdapterConfiglogger is required, auth fields are split across union types
  • TelegramAdapterConfigbotToken is required
  • LinearAdapterConfigwebhookSecret, userName, and logger are required
  • GitHubAdapterConfigwebhookSecret, userName, and logger are required

The factory functions (e.g. createSlackAdapter, createDiscordAdapter) already resolve these from env vars, but the class constructors don't — they expect the values to be present.

Desired Behavior

Make all adapter config fields optional (or provide sensible defaults), so that:

  1. Users can call new SlackAdapter({}) or new DiscordAdapter({}) and have env vars auto-resolved
  2. Explicit config values override env vars when provided
  3. The factory functions remain the recommended API, but direct construction also "just works" with env vars

This would align the class constructors with the factory functions, which already implement the config ?? process.env.X pattern.

Context

Raised by @cramforce — who originally wrote the current explicit config pattern and now wants to make it more ergonomic.

Affected Packages

  • @chat-adapter/slack
  • @chat-adapter/discord
  • @chat-adapter/teams
  • @chat-adapter/gchat
  • @chat-adapter/telegram
  • @chat-adapter/linear
  • @chat-adapter/github

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions