Skip to content

Platform adapters should have account identifier inference implemented #304

@noelblaschke

Description

@noelblaschke

Problem Statement

Hey guys,

appreciate your amazing work!

Right now using e.g. the matrix (beeper) platform adapter does not allow to use the chat.openDm(userId) functionality because

private inferAdapterFromUserId(userId: string): Adapter {
has a fixed set of inference rules and will throw an error because matrix adapter inference is not implemented in here.

Can't go on checking if it's even working for now..

Proposed Solution

A platform adapter should implement it's own inference rules and register it's inference rule to the chat sdk.

If an rule already exists it should be overriden or throw an exception - whatever is your opinion on that.

Alternatives Considered

Other approaches are welcome

Use Case

import { createMatrixAdapter } from "@beeper/chat-adapter-matrix";
import { Chat } from "chat";

const adapterOptions = {
  baseURL: process.env.MATRIX_BASE_URL!,
  auth: {
    type: "accessToken",
    accessToken: process.env.MATRIX_ACCESS_TOKEN!,
    userID: process.env.MATRIX_USER_ID,
  },
} satisfies MatrixAdapterConfig;


export const bot = new Chat({
  userName: "botbotbot",
  adapters: {
    matrix: createMatrixAdapter(adapterOptions),
  },
  state: createMemoryState(),
});

await bot.initialize();

const dmThread = await bot.openDM("@user_id:matrix.org");
await dmThread.post("I'm aliveeeeee");

Priority

None

Contribution

  • I am willing to help implement this feature

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions