feat(channel): pass conversation type through to agent gateway and persist in route

Propagate conversation type (direct/group/thread) from channel adapters
all the way to the agent prompt. Store conversation_type on bot_channel_routes
so the bot knows whether a message originates from a p2p chat, group, or thread.

Schema changes are folded into the 0001 init migration (destructive update).
This commit is contained in:
BBQ
2026-02-13 05:10:35 +08:00
parent 0406f42e86
commit faaadf14c5
18 changed files with 173 additions and 153 deletions
+1
View File
@@ -207,6 +207,7 @@ CREATE TABLE IF NOT EXISTS bot_channel_routes (
channel_config_id UUID REFERENCES bot_channel_configs(id) ON DELETE SET NULL,
external_conversation_id TEXT NOT NULL,
external_thread_id TEXT,
conversation_type TEXT,
default_reply_target TEXT,
metadata JSONB NOT NULL DEFAULT '{}'::jsonb,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
@@ -0,0 +1,2 @@
-- 0002_channel_identity_avatar (down)
ALTER TABLE channel_identities DROP COLUMN IF EXISTS avatar_url;
@@ -0,0 +1,3 @@
-- 0002_channel_identity_avatar
-- Add avatar_url column to channel_identities for sender profile display.
ALTER TABLE channel_identities ADD COLUMN IF NOT EXISTS avatar_url TEXT;
@@ -0,0 +1,2 @@
-- 0003_route_conversation_type (down)
ALTER TABLE bot_channel_routes DROP COLUMN IF EXISTS conversation_type;
@@ -0,0 +1,3 @@
-- 0003_route_conversation_type
-- Add conversation_type column to bot_channel_routes for conversation context.
ALTER TABLE bot_channel_routes ADD COLUMN IF NOT EXISTS conversation_type TEXT;
+6 -1
View File
@@ -1,6 +1,6 @@
-- name: CreateChatRoute :one
INSERT INTO bot_channel_routes (
bot_id, channel_type, channel_config_id, external_conversation_id, external_thread_id, default_reply_target, metadata
bot_id, channel_type, channel_config_id, external_conversation_id, external_thread_id, conversation_type, default_reply_target, metadata
)
VALUES (
sqlc.arg(bot_id),
@@ -8,6 +8,7 @@ VALUES (
sqlc.narg(channel_config_id)::uuid,
sqlc.arg(conversation_id),
sqlc.narg(thread_id)::text,
sqlc.narg(conversation_type)::text,
sqlc.narg(reply_target)::text,
sqlc.arg(metadata)
)
@@ -19,6 +20,7 @@ RETURNING
channel_config_id,
external_conversation_id AS conversation_id,
external_thread_id AS thread_id,
conversation_type,
default_reply_target AS reply_target,
metadata,
created_at,
@@ -33,6 +35,7 @@ SELECT
channel_config_id,
external_conversation_id AS conversation_id,
external_thread_id AS thread_id,
conversation_type,
default_reply_target AS reply_target,
metadata,
created_at,
@@ -53,6 +56,7 @@ SELECT
channel_config_id,
external_conversation_id AS conversation_id,
external_thread_id AS thread_id,
conversation_type,
default_reply_target AS reply_target,
metadata,
created_at,
@@ -69,6 +73,7 @@ SELECT
channel_config_id,
external_conversation_id AS conversation_id,
external_thread_id AS thread_id,
conversation_type,
default_reply_target AS reply_target,
metadata,
created_at,