feat(im): add Telegram platform integration
Add Telegram Bot API adapter supporting both webhook and long-polling modes with streaming replies via editMessageText, file download via getFile API, and timing-safe secret token verification.
This commit is contained in:
@@ -182,7 +182,7 @@ export interface IMChannel {
|
||||
id: string;
|
||||
tenant_id?: number;
|
||||
agent_id: string;
|
||||
platform: 'wecom' | 'feishu' | 'slack';
|
||||
platform: 'wecom' | 'feishu' | 'slack' | 'telegram';
|
||||
name: string;
|
||||
enabled: boolean;
|
||||
mode: 'webhook' | 'websocket';
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<div class="channel-info-top">
|
||||
<div class="channel-main">
|
||||
<span class="platform-badge" :class="channel.platform">
|
||||
{{ channel.platform === 'wecom' ? $t('agentEditor.im.wecom') : channel.platform === 'feishu' ? $t('agentEditor.im.feishu') : $t('agentEditor.im.slack') }}
|
||||
{{ platformLabel(channel.platform) }}
|
||||
</span>
|
||||
<span class="channel-name">{{ channel.name || $t('agentEditor.im.unnamed') }}</span>
|
||||
</div>
|
||||
@@ -89,6 +89,7 @@
|
||||
<t-radio-button value="wecom">{{ $t('agentEditor.im.wecom') }}</t-radio-button>
|
||||
<t-radio-button value="feishu">{{ $t('agentEditor.im.feishu') }}</t-radio-button>
|
||||
<t-radio-button value="slack">{{ $t('agentEditor.im.slack') }}</t-radio-button>
|
||||
<t-radio-button value="telegram">{{ $t('agentEditor.im.telegram') }}</t-radio-button>
|
||||
</t-radio-group>
|
||||
</div>
|
||||
|
||||
@@ -236,6 +237,28 @@
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<!-- Telegram credentials -->
|
||||
<template v-if="formData.platform === 'telegram'">
|
||||
<div class="platform-link-hint">
|
||||
<t-icon name="jump" class="hint-link-icon" />
|
||||
<a href="https://t.me/BotFather" target="_blank" rel="noopener noreferrer" class="hint-link">
|
||||
{{ $t('agentEditor.im.telegramConsole') }}
|
||||
</a>
|
||||
<span class="hint-text">{{ $t('agentEditor.im.consoleTip') }}</span>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label">Bot Token</label>
|
||||
<t-input v-model="formData.credentials.bot_token" type="password" placeholder="123456789:AABBccdd..." />
|
||||
</div>
|
||||
<template v-if="formData.mode === 'webhook'">
|
||||
<div class="form-item">
|
||||
<label class="form-label">Secret Token</label>
|
||||
<t-input v-model="formData.credentials.secret_token" type="password" placeholder="Secret Token (optional)" />
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
</div>
|
||||
</t-dialog>
|
||||
</div>
|
||||
@@ -266,7 +289,7 @@ const knowledgeBases = ref<{ id: string; name: string }[]>([]);
|
||||
const defaultCredentials = (): Record<string, any> => ({});
|
||||
|
||||
const formData = ref({
|
||||
platform: 'wecom' as 'wecom' | 'feishu' | 'slack',
|
||||
platform: 'wecom' as 'wecom' | 'feishu' | 'slack' | 'telegram',
|
||||
name: '',
|
||||
mode: 'websocket' as 'webhook' | 'websocket',
|
||||
output_mode: 'stream' as 'stream' | 'full',
|
||||
@@ -274,6 +297,11 @@ const formData = ref({
|
||||
credentials: defaultCredentials(),
|
||||
});
|
||||
|
||||
function platformLabel(platform: string): string {
|
||||
const key = `agentEditor.im.${platform}`;
|
||||
return t(key);
|
||||
}
|
||||
|
||||
async function loadChannels() {
|
||||
loading.value = true;
|
||||
try {
|
||||
@@ -510,6 +538,12 @@ onMounted(() => {
|
||||
background: rgba(224, 30, 90, 0.08);
|
||||
color: #e01e5a;
|
||||
}
|
||||
|
||||
&.telegram {
|
||||
background: rgba(38, 166, 219, 0.08);
|
||||
color: #26a6db;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.channel-name {
|
||||
|
||||
@@ -3182,10 +3182,11 @@ export default {
|
||||
},
|
||||
im: {
|
||||
title: 'IM Integration',
|
||||
description: 'Connect agent to instant messaging platforms like WeCom, Feishu and Slack',
|
||||
description: 'Connect agent to instant messaging platforms like WeCom, Feishu, Slack and Telegram',
|
||||
wecom: 'WeCom',
|
||||
feishu: 'Feishu',
|
||||
slack: 'Slack',
|
||||
telegram: 'Telegram',
|
||||
addChannel: 'Add Channel',
|
||||
editChannel: 'Edit Channel',
|
||||
deleteConfirm: 'Are you sure you want to delete this channel? This action cannot be undone.',
|
||||
@@ -3203,6 +3204,7 @@ export default {
|
||||
wecomConsole: 'WeCom Admin',
|
||||
feishuConsole: 'Feishu Open Platform',
|
||||
slackConsole: 'Slack API Console',
|
||||
telegramConsole: 'Telegram BotFather',
|
||||
modeHint: 'WebSocket is recommended for easier setup',
|
||||
consoleTip: 'to get credentials',
|
||||
fileKnowledgeBase: 'File Storage Knowledge Base',
|
||||
|
||||
@@ -3212,10 +3212,11 @@ export default {
|
||||
},
|
||||
im: {
|
||||
title: "IM 통합",
|
||||
description: "에이전트를 WeCom, Feishu, Slack 등 인스턴트 메시징 플랫폼에 연결",
|
||||
description: "에이전트를 WeCom, Feishu, Slack, Telegram 등 인스턴트 메시징 플랫폼에 연결",
|
||||
wecom: "WeCom",
|
||||
feishu: "Feishu",
|
||||
slack: "Slack",
|
||||
telegram: "Telegram",
|
||||
addChannel: "채널 추가",
|
||||
editChannel: "채널 편집",
|
||||
deleteConfirm: "이 채널을 삭제하시겠습니까? 이 작업은 되돌릴 수 없습니다.",
|
||||
@@ -3233,6 +3234,7 @@ export default {
|
||||
wecomConsole: "WeCom 관리 콘솔",
|
||||
feishuConsole: "Feishu 개발 플랫폼",
|
||||
slackConsole: "Slack API 콘솔",
|
||||
telegramConsole: "Telegram BotFather",
|
||||
modeHint: "WebSocket 방식이 설정이 더 간편하여 권장됩니다",
|
||||
consoleTip: "자격 증명 정보를 가져오세요",
|
||||
fileKnowledgeBase: "파일 저장 지식 베이스",
|
||||
|
||||
@@ -2845,10 +2845,11 @@ export default {
|
||||
},
|
||||
im: {
|
||||
title: 'Интеграция IM',
|
||||
description: 'Подключите агента к платформам мгновенных сообщений, таким как WeCom, Feishu и Slack',
|
||||
description: 'Подключите агента к платформам мгновенных сообщений, таким как WeCom, Feishu, Slack и Telegram',
|
||||
wecom: 'WeCom',
|
||||
feishu: 'Feishu',
|
||||
slack: 'Slack',
|
||||
telegram: 'Telegram',
|
||||
addChannel: 'Добавить канал',
|
||||
editChannel: 'Редактировать канал',
|
||||
deleteConfirm: 'Вы уверены, что хотите удалить этот канал? Это действие не может быть отменено.',
|
||||
@@ -2866,6 +2867,7 @@ export default {
|
||||
wecomConsole: 'Консоль WeCom',
|
||||
feishuConsole: 'Платформа Feishu',
|
||||
slackConsole: 'Консоль Slack API',
|
||||
telegramConsole: 'Telegram BotFather',
|
||||
modeHint: 'Рекомендуется WebSocket — проще настроить',
|
||||
consoleTip: 'для получения учётных данных',
|
||||
fileKnowledgeBase: 'База знаний для файлов',
|
||||
|
||||
@@ -3157,10 +3157,11 @@ export default {
|
||||
},
|
||||
im: {
|
||||
title: "IM 集成",
|
||||
description: "将智能体接入即时通讯平台,支持企业微信、飞书和Slack",
|
||||
description: "将智能体接入即时通讯平台,支持企业微信、飞书、Slack和Telegram",
|
||||
wecom: "企业微信",
|
||||
feishu: "飞书",
|
||||
slack: "Slack",
|
||||
telegram: "Telegram",
|
||||
addChannel: "添加渠道",
|
||||
editChannel: "编辑渠道",
|
||||
deleteConfirm: "确定删除该渠道?删除后无法恢复。",
|
||||
@@ -3178,6 +3179,7 @@ export default {
|
||||
wecomConsole: "企业微信管理后台",
|
||||
feishuConsole: "飞书开放平台",
|
||||
slackConsole: "Slack API 控制台",
|
||||
telegramConsole: "Telegram BotFather",
|
||||
modeHint: "推荐使用 WebSocket 方式接入,配置更简单",
|
||||
consoleTip: "前往获取凭证信息",
|
||||
fileKnowledgeBase: "文件保存知识库",
|
||||
|
||||
Reference in New Issue
Block a user