Downcity
Integration Patterns

Inject ChatService into a Local Agent

Typical way to explicitly pass a ChatService instance in SDK mode

Inject ChatService into a Local Agent

If you want the SDK process to own chat service capability, pass the service instance directly:

import { Agent, ChatService } from "@downcity/agent";

const agent = new Agent({
  id: "repo-helper",
  path: "/path/to/project",
  tools: {},
  services: [
    new ChatService({
      telegram: {
        botToken: process.env.TELEGRAM_BOT_TOKEN!,
      },
    }),
  ],
});

Good fit for:

  • when your application code should control channel lifecycle directly
  • when you do not want to depend on external project-runtime auto-assembly

If you want the SDK process itself to send and receive messages through channels, this explicit injection model is usually much easier to reason about.

Continue with: