From ea638cab80d73ddec1b1ff1ccdd611db3f73110c Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Tue, 31 Mar 2026 00:29:24 +0800 Subject: [PATCH] feat: add help links for message platform adapters in YAML and update documentation retrieval logic --- .../pkg/platform/sources/aiocqhttp.yaml | 4 +++ .../pkg/platform/sources/dingtalk.yaml | 4 +++ src/langbot/pkg/platform/sources/discord.yaml | 4 +++ src/langbot/pkg/platform/sources/kook.yaml | 4 +++ src/langbot/pkg/platform/sources/lark.yaml | 4 +++ src/langbot/pkg/platform/sources/line.yaml | 4 +++ .../pkg/platform/sources/officialaccount.yaml | 4 +++ .../pkg/platform/sources/openclaw_weixin.yaml | 4 +++ .../pkg/platform/sources/qqofficial.yaml | 4 +++ src/langbot/pkg/platform/sources/satori.yaml | 4 +++ src/langbot/pkg/platform/sources/slack.yaml | 4 +++ .../pkg/platform/sources/telegram.yaml | 4 +++ .../pkg/platform/sources/wechatpad.yaml | 4 +++ src/langbot/pkg/platform/sources/wecom.yaml | 4 +++ .../pkg/platform/sources/wecombot.yaml | 4 +++ src/langbot/pkg/platform/sources/wecomcs.yaml | 4 +++ .../home/bots/components/bot-form/BotForm.tsx | 17 ++++++++- web/src/app/infra/entities/adapter-docs.ts | 36 +++++-------------- web/src/app/infra/entities/api/index.ts | 1 + web/src/app/wizard/page.tsx | 7 ++-- 20 files changed, 94 insertions(+), 31 deletions(-) diff --git a/src/langbot/pkg/platform/sources/aiocqhttp.yaml b/src/langbot/pkg/platform/sources/aiocqhttp.yaml index e073fe57..b93a2524 100644 --- a/src/langbot/pkg/platform/sources/aiocqhttp.yaml +++ b/src/langbot/pkg/platform/sources/aiocqhttp.yaml @@ -14,6 +14,10 @@ metadata: spec: categories: - protocol + help_links: + zh: https://link.langbot.app/zh/platforms/aiocqhttp + en: https://link.langbot.app/en/platforms/aiocqhttp + ja: https://link.langbot.app/ja/platforms/aiocqhttp config: - name: host label: diff --git a/src/langbot/pkg/platform/sources/dingtalk.yaml b/src/langbot/pkg/platform/sources/dingtalk.yaml index 160e5114..8b2fc955 100644 --- a/src/langbot/pkg/platform/sources/dingtalk.yaml +++ b/src/langbot/pkg/platform/sources/dingtalk.yaml @@ -14,6 +14,10 @@ metadata: spec: categories: - china + help_links: + zh: https://link.langbot.app/zh/platforms/dingtalk + en: https://link.langbot.app/en/platforms/dingtalk + ja: https://link.langbot.app/ja/platforms/dingtalk config: - name: client_id label: diff --git a/src/langbot/pkg/platform/sources/discord.yaml b/src/langbot/pkg/platform/sources/discord.yaml index 0f963c76..28149cbd 100644 --- a/src/langbot/pkg/platform/sources/discord.yaml +++ b/src/langbot/pkg/platform/sources/discord.yaml @@ -23,6 +23,10 @@ spec: categories: - popular - global + help_links: + zh: https://link.langbot.app/zh/platforms/discord + en: https://link.langbot.app/en/platforms/discord + ja: https://link.langbot.app/ja/platforms/discord config: - name: client_id label: diff --git a/src/langbot/pkg/platform/sources/kook.yaml b/src/langbot/pkg/platform/sources/kook.yaml index cca9db59..c63d35ee 100644 --- a/src/langbot/pkg/platform/sources/kook.yaml +++ b/src/langbot/pkg/platform/sources/kook.yaml @@ -14,6 +14,10 @@ metadata: spec: categories: - china + help_links: + zh: https://link.langbot.app/zh/platforms/kook + en: https://link.langbot.app/en/platforms/kook + ja: https://link.langbot.app/ja/platforms/kook config: - name: token label: diff --git a/src/langbot/pkg/platform/sources/lark.yaml b/src/langbot/pkg/platform/sources/lark.yaml index 1217d6ca..0e6093cb 100644 --- a/src/langbot/pkg/platform/sources/lark.yaml +++ b/src/langbot/pkg/platform/sources/lark.yaml @@ -18,6 +18,10 @@ spec: - popular - china - global + help_links: + zh: https://link.langbot.app/zh/platforms/lark + en: https://link.langbot.app/en/platforms/lark + ja: https://link.langbot.app/ja/platforms/lark config: - name: app_id label: diff --git a/src/langbot/pkg/platform/sources/line.yaml b/src/langbot/pkg/platform/sources/line.yaml index 05a1ee78..5ee53812 100644 --- a/src/langbot/pkg/platform/sources/line.yaml +++ b/src/langbot/pkg/platform/sources/line.yaml @@ -21,6 +21,10 @@ metadata: spec: categories: - global + help_links: + zh: https://link.langbot.app/zh/platforms/line + en: https://link.langbot.app/en/platforms/line + ja: https://link.langbot.app/ja/platforms/line config: - name: webhook_url label: diff --git a/src/langbot/pkg/platform/sources/officialaccount.yaml b/src/langbot/pkg/platform/sources/officialaccount.yaml index 6e6952b2..9376c3fd 100644 --- a/src/langbot/pkg/platform/sources/officialaccount.yaml +++ b/src/langbot/pkg/platform/sources/officialaccount.yaml @@ -14,6 +14,10 @@ metadata: spec: categories: - china + help_links: + zh: https://link.langbot.app/zh/platforms/officialaccount + en: https://link.langbot.app/en/platforms/officialaccount + ja: https://link.langbot.app/ja/platforms/officialaccount config: - name: webhook_url label: diff --git a/src/langbot/pkg/platform/sources/openclaw_weixin.yaml b/src/langbot/pkg/platform/sources/openclaw_weixin.yaml index ac1a206b..5d3d3925 100644 --- a/src/langbot/pkg/platform/sources/openclaw_weixin.yaml +++ b/src/langbot/pkg/platform/sources/openclaw_weixin.yaml @@ -15,6 +15,10 @@ spec: categories: - popular - china + help_links: + zh: https://link.langbot.app/zh/platforms/openclaw_weixin + en: https://link.langbot.app/en/platforms/openclaw_weixin + ja: https://link.langbot.app/ja/platforms/openclaw_weixin config: - name: base_url label: diff --git a/src/langbot/pkg/platform/sources/qqofficial.yaml b/src/langbot/pkg/platform/sources/qqofficial.yaml index ad526e49..48ad7ffd 100644 --- a/src/langbot/pkg/platform/sources/qqofficial.yaml +++ b/src/langbot/pkg/platform/sources/qqofficial.yaml @@ -14,6 +14,10 @@ metadata: spec: categories: - china + help_links: + zh: https://link.langbot.app/zh/platforms/qqofficial + en: https://link.langbot.app/en/platforms/qqofficial + ja: https://link.langbot.app/ja/platforms/qqofficial config: - name: webhook_url label: diff --git a/src/langbot/pkg/platform/sources/satori.yaml b/src/langbot/pkg/platform/sources/satori.yaml index eb3aacbc..a2506bb6 100644 --- a/src/langbot/pkg/platform/sources/satori.yaml +++ b/src/langbot/pkg/platform/sources/satori.yaml @@ -20,6 +20,10 @@ metadata: spec: categories: - protocol + help_links: + zh: https://link.langbot.app/zh/platforms/satori + en: https://link.langbot.app/en/platforms/satori + ja: https://link.langbot.app/ja/platforms/satori config: - name: platform label: diff --git a/src/langbot/pkg/platform/sources/slack.yaml b/src/langbot/pkg/platform/sources/slack.yaml index 252431e3..f1a2e740 100644 --- a/src/langbot/pkg/platform/sources/slack.yaml +++ b/src/langbot/pkg/platform/sources/slack.yaml @@ -23,6 +23,10 @@ spec: categories: - popular - global + help_links: + zh: https://link.langbot.app/zh/platforms/slack + en: https://link.langbot.app/en/platforms/slack + ja: https://link.langbot.app/ja/platforms/slack config: - name: webhook_url label: diff --git a/src/langbot/pkg/platform/sources/telegram.yaml b/src/langbot/pkg/platform/sources/telegram.yaml index 9291bbd4..f652ae42 100644 --- a/src/langbot/pkg/platform/sources/telegram.yaml +++ b/src/langbot/pkg/platform/sources/telegram.yaml @@ -23,6 +23,10 @@ spec: categories: - popular - global + help_links: + zh: https://link.langbot.app/zh/platforms/telegram + en: https://link.langbot.app/en/platforms/telegram + ja: https://link.langbot.app/ja/platforms/telegram config: - name: token label: diff --git a/src/langbot/pkg/platform/sources/wechatpad.yaml b/src/langbot/pkg/platform/sources/wechatpad.yaml index 1d7e2b41..e02c6aa6 100644 --- a/src/langbot/pkg/platform/sources/wechatpad.yaml +++ b/src/langbot/pkg/platform/sources/wechatpad.yaml @@ -14,6 +14,10 @@ metadata: spec: categories: - china + help_links: + zh: https://link.langbot.app/zh/platforms/wechatpad + en: https://link.langbot.app/en/platforms/wechatpad + ja: https://link.langbot.app/ja/platforms/wechatpad config: - name: wechatpad_url label: diff --git a/src/langbot/pkg/platform/sources/wecom.yaml b/src/langbot/pkg/platform/sources/wecom.yaml index 0fe6cac7..d232414b 100644 --- a/src/langbot/pkg/platform/sources/wecom.yaml +++ b/src/langbot/pkg/platform/sources/wecom.yaml @@ -15,6 +15,10 @@ spec: categories: - popular - china + help_links: + zh: https://link.langbot.app/zh/platforms/wecom + en: https://link.langbot.app/en/platforms/wecom + ja: https://link.langbot.app/ja/platforms/wecom config: - name: webhook_url label: diff --git a/src/langbot/pkg/platform/sources/wecombot.yaml b/src/langbot/pkg/platform/sources/wecombot.yaml index 2405a7a3..08b7315a 100644 --- a/src/langbot/pkg/platform/sources/wecombot.yaml +++ b/src/langbot/pkg/platform/sources/wecombot.yaml @@ -14,6 +14,10 @@ metadata: spec: categories: - china + help_links: + zh: https://link.langbot.app/zh/platforms/wecombot + en: https://link.langbot.app/en/platforms/wecombot + ja: https://link.langbot.app/ja/platforms/wecombot config: - name: BotId label: diff --git a/src/langbot/pkg/platform/sources/wecomcs.yaml b/src/langbot/pkg/platform/sources/wecomcs.yaml index b14b4885..27abc010 100644 --- a/src/langbot/pkg/platform/sources/wecomcs.yaml +++ b/src/langbot/pkg/platform/sources/wecomcs.yaml @@ -14,6 +14,10 @@ metadata: spec: categories: - china + help_links: + zh: https://link.langbot.app/zh/platforms/wecomcs + en: https://link.langbot.app/en/platforms/wecomcs + ja: https://link.langbot.app/ja/platforms/wecomcs config: - name: webhook_url label: diff --git a/web/src/app/home/bots/components/bot-form/BotForm.tsx b/web/src/app/home/bots/components/bot-form/BotForm.tsx index 4569da48..bc8e5e56 100644 --- a/web/src/app/home/bots/components/bot-form/BotForm.tsx +++ b/web/src/app/home/bots/components/bot-form/BotForm.tsx @@ -105,6 +105,9 @@ export default function BotForm({ const [adapterDescriptionList, setAdapterDescriptionList] = useState< Record >({}); + const [adapterHelpLinks, setAdapterHelpLinks] = useState< + Record> + >({}); const [pipelineNameList, setPipelineNameList] = useState( [], @@ -212,6 +215,18 @@ export default function BotForm({ ), ); + setAdapterHelpLinks( + adaptersRes.adapters.reduce( + (acc, item) => { + if (item.spec.help_links) { + acc[item.name] = item.spec.help_links; + } + return acc; + }, + {} as Record>, + ), + ); + adaptersRes.adapters.forEach((rawAdapter) => { adapterNameToDynamicConfigMap.set( rawAdapter.name, @@ -531,7 +546,7 @@ export default function BotForm({ {currentAdapter && (() => { const docUrl = getAdapterDocUrl( - currentAdapter, + adapterHelpLinks[currentAdapter], i18n.language, ); return docUrl ? ( diff --git a/web/src/app/infra/entities/adapter-docs.ts b/web/src/app/infra/entities/adapter-docs.ts index 64ae9b1a..fbafc3c6 100644 --- a/web/src/app/infra/entities/adapter-docs.ts +++ b/web/src/app/infra/entities/adapter-docs.ts @@ -1,12 +1,15 @@ /** - * Returns the documentation URL for a given adapter name, - * using link.langbot.app short links. + * Resolves the documentation URL for a given adapter from its + * spec.help_links map, selecting the best match for the current locale + * with a fallback to English. */ export function getAdapterDocUrl( - adapterName: string, + helpLinks: Record | undefined, locale: string, ): string | null { - // Map locale to doc language prefix + if (!helpLinks) return null; + + // Map locale to simplified language key let lang: string; if (locale.startsWith('zh')) { lang = 'zh'; @@ -16,28 +19,5 @@ export function getAdapterDocUrl( lang = 'en'; } - // Only adapters with dedicated doc pages - const ADAPTER_DOC_SLUGS: Record = { - telegram: 'telegram', - discord: 'discord', - slack: 'slack', - line: 'line', - kook: 'kook', - lark: 'lark', - dingtalk: 'dingtalk', - aiocqhttp: 'aiocqhttp', - qqofficial: 'qqofficial', - wecom: 'wecom', - wecomcs: 'wecomcs', - wecombot: 'wecombot', - officialaccount: 'officialaccount', - wechatpad: 'wechatpad', - openclaw_weixin: 'openclaw_weixin', - satori: 'satori', - }; - - const slug = ADAPTER_DOC_SLUGS[adapterName]; - if (!slug) return null; - - return `https://link.langbot.app/${lang}/platforms/${slug}`; + return helpLinks[lang] ?? helpLinks['en'] ?? null; } diff --git a/web/src/app/infra/entities/api/index.ts b/web/src/app/infra/entities/api/index.ts index 2819133a..56b79888 100644 --- a/web/src/app/infra/entities/api/index.ts +++ b/web/src/app/infra/entities/api/index.ts @@ -118,6 +118,7 @@ export interface Adapter { icon?: string; spec: { categories?: string[]; + help_links?: Record; config: IDynamicFormItemSchema[]; }; } diff --git a/web/src/app/wizard/page.tsx b/web/src/app/wizard/page.tsx index c3b9831e..3d5e435f 100644 --- a/web/src/app/wizard/page.tsx +++ b/web/src/app/wizard/page.tsx @@ -803,7 +803,7 @@ function StepPlatform({

{(() => { const docUrl = getAdapterDocUrl( - adapter.name, + adapter.spec.help_links, i18n.language, ); return docUrl ? ( @@ -896,8 +896,11 @@ function StepBotConfig({ {selectedAdapterName && (() => { + const selectedAdapter = adapters.find( + (a) => a.name === selectedAdapterName, + ); const docUrl = getAdapterDocUrl( - selectedAdapterName, + selectedAdapter?.spec.help_links, i18n.language, ); return docUrl ? (