feat: add help links for message platform adapters in YAML and update documentation retrieval logic

This commit is contained in:
Junyan Qin
2026-03-31 00:29:24 +08:00
parent 7129dd536e
commit ea638cab80
20 changed files with 94 additions and 31 deletions

View File

@@ -14,6 +14,10 @@ metadata:
spec: spec:
categories: categories:
- protocol - 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: config:
- name: host - name: host
label: label:

View File

@@ -14,6 +14,10 @@ metadata:
spec: spec:
categories: categories:
- china - 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: config:
- name: client_id - name: client_id
label: label:

View File

@@ -23,6 +23,10 @@ spec:
categories: categories:
- popular - popular
- global - 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: config:
- name: client_id - name: client_id
label: label:

View File

@@ -14,6 +14,10 @@ metadata:
spec: spec:
categories: categories:
- china - 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: config:
- name: token - name: token
label: label:

View File

@@ -18,6 +18,10 @@ spec:
- popular - popular
- china - china
- global - 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: config:
- name: app_id - name: app_id
label: label:

View File

@@ -21,6 +21,10 @@ metadata:
spec: spec:
categories: categories:
- global - 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: config:
- name: webhook_url - name: webhook_url
label: label:

View File

@@ -14,6 +14,10 @@ metadata:
spec: spec:
categories: categories:
- china - 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: config:
- name: webhook_url - name: webhook_url
label: label:

View File

@@ -15,6 +15,10 @@ spec:
categories: categories:
- popular - popular
- china - 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: config:
- name: base_url - name: base_url
label: label:

View File

@@ -14,6 +14,10 @@ metadata:
spec: spec:
categories: categories:
- china - 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: config:
- name: webhook_url - name: webhook_url
label: label:

View File

@@ -20,6 +20,10 @@ metadata:
spec: spec:
categories: categories:
- protocol - 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: config:
- name: platform - name: platform
label: label:

View File

@@ -23,6 +23,10 @@ spec:
categories: categories:
- popular - popular
- global - 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: config:
- name: webhook_url - name: webhook_url
label: label:

View File

@@ -23,6 +23,10 @@ spec:
categories: categories:
- popular - popular
- global - 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: config:
- name: token - name: token
label: label:

View File

@@ -14,6 +14,10 @@ metadata:
spec: spec:
categories: categories:
- china - 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: config:
- name: wechatpad_url - name: wechatpad_url
label: label:

View File

@@ -15,6 +15,10 @@ spec:
categories: categories:
- popular - popular
- china - 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: config:
- name: webhook_url - name: webhook_url
label: label:

View File

@@ -14,6 +14,10 @@ metadata:
spec: spec:
categories: categories:
- china - 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: config:
- name: BotId - name: BotId
label: label:

View File

@@ -14,6 +14,10 @@ metadata:
spec: spec:
categories: categories:
- china - 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: config:
- name: webhook_url - name: webhook_url
label: label:

View File

@@ -105,6 +105,9 @@ export default function BotForm({
const [adapterDescriptionList, setAdapterDescriptionList] = useState< const [adapterDescriptionList, setAdapterDescriptionList] = useState<
Record<string, string> Record<string, string>
>({}); >({});
const [adapterHelpLinks, setAdapterHelpLinks] = useState<
Record<string, Record<string, string>>
>({});
const [pipelineNameList, setPipelineNameList] = useState<IPipelineEntity[]>( const [pipelineNameList, setPipelineNameList] = useState<IPipelineEntity[]>(
[], [],
@@ -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<string, Record<string, string>>,
),
);
adaptersRes.adapters.forEach((rawAdapter) => { adaptersRes.adapters.forEach((rawAdapter) => {
adapterNameToDynamicConfigMap.set( adapterNameToDynamicConfigMap.set(
rawAdapter.name, rawAdapter.name,
@@ -531,7 +546,7 @@ export default function BotForm({
{currentAdapter && {currentAdapter &&
(() => { (() => {
const docUrl = getAdapterDocUrl( const docUrl = getAdapterDocUrl(
currentAdapter, adapterHelpLinks[currentAdapter],
i18n.language, i18n.language,
); );
return docUrl ? ( return docUrl ? (

View File

@@ -1,12 +1,15 @@
/** /**
* Returns the documentation URL for a given adapter name, * Resolves the documentation URL for a given adapter from its
* using link.langbot.app short links. * spec.help_links map, selecting the best match for the current locale
* with a fallback to English.
*/ */
export function getAdapterDocUrl( export function getAdapterDocUrl(
adapterName: string, helpLinks: Record<string, string> | undefined,
locale: string, locale: string,
): string | null { ): string | null {
// Map locale to doc language prefix if (!helpLinks) return null;
// Map locale to simplified language key
let lang: string; let lang: string;
if (locale.startsWith('zh')) { if (locale.startsWith('zh')) {
lang = 'zh'; lang = 'zh';
@@ -16,28 +19,5 @@ export function getAdapterDocUrl(
lang = 'en'; lang = 'en';
} }
// Only adapters with dedicated doc pages return helpLinks[lang] ?? helpLinks['en'] ?? null;
const ADAPTER_DOC_SLUGS: Record<string, string> = {
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}`;
} }

View File

@@ -118,6 +118,7 @@ export interface Adapter {
icon?: string; icon?: string;
spec: { spec: {
categories?: string[]; categories?: string[];
help_links?: Record<string, string>;
config: IDynamicFormItemSchema[]; config: IDynamicFormItemSchema[];
}; };
} }

View File

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