feat(routing): route replies to originating channel
Implement reply routing based on OriginatingChannel/OriginatingTo fields. This ensures replies go back to the provider where the message originated instead of using the session's lastChannel. Changes: - Add OriginatingChannel/OriginatingTo fields to MsgContext (templating.ts) - Add originatingChannel/originatingTo fields to FollowupRun (queue.ts) - Create route-reply.ts with provider-agnostic router - Update all providers (Telegram, Slack, Discord, Signal, iMessage) to pass originating channel info - Update reply.ts to pass originating channel to followupRun - Update followup-runner.ts to use route-reply for originating channels This addresses the issue where messages from one provider (e.g., Slack) would receive replies on a different provider (e.g., Telegram) because the queue used the last active dispatcher instead of the originating one.
This commit is contained in:
committed by
Peter Steinberger
parent
514fcfe77e
commit
9d50ebad7d
@@ -1,3 +1,13 @@
|
||||
/** Valid provider channels for message routing. */
|
||||
export type OriginatingChannelType =
|
||||
| "telegram"
|
||||
| "slack"
|
||||
| "discord"
|
||||
| "signal"
|
||||
| "imessage"
|
||||
| "whatsapp"
|
||||
| "webchat";
|
||||
|
||||
export type MsgContext = {
|
||||
Body?: string;
|
||||
From?: string;
|
||||
@@ -38,6 +48,17 @@ export type MsgContext = {
|
||||
MessageThreadId?: number;
|
||||
/** Telegram forum supergroup marker. */
|
||||
IsForum?: boolean;
|
||||
/**
|
||||
* Originating channel for reply routing.
|
||||
* When set, replies should be routed back to this provider
|
||||
* instead of using lastChannel from the session.
|
||||
*/
|
||||
OriginatingChannel?: OriginatingChannelType;
|
||||
/**
|
||||
* Originating destination for reply routing.
|
||||
* The chat/channel/user ID where the reply should be sent.
|
||||
*/
|
||||
OriginatingTo?: string;
|
||||
};
|
||||
|
||||
export type TemplateContext = MsgContext & {
|
||||
|
||||
Reference in New Issue
Block a user