6bf8bebf51
CI / Test and Build (push) Failing after 1s
CI / Migrate Dev DB (push) Has been skipped
CI / Migrate DB (push) Has been skipped
CodeQL / Analyze actions (push) Has been cancelled
CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI / Detect Version (push) Has been cancelled
CI / Detect Desktop Changes (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/cron.Dockerfile, ubuntu-latest, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build AMD64 (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/cron.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/db.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/pii.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/realtime.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-8vcpu-ubuntu-2404-arm, ./docker/app.Dockerfile, linux-arm64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
Helm Chart / Lint, test, and validate chart (push) Has been cancelled
Helm Chart / Chart version bumped (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Build Dev ECR (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core) (push) Has been cancelled
CI / Promote Images (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Check Desktop Signing Secrets (push) Has been cancelled
CI / Desktop Release (push) Has been cancelled
CI / Create Desktop Prerelease (push) Has been cancelled
CI / Desktop Prerelease Build (push) Has been cancelled
CI / Publish Desktop Prerelease (push) Has been cancelled
CI / Prune Desktop Prereleases (push) Has been cancelled
Helm Chart / Install on kind and run helm test (push) Has been cancelled
150 lines
4.3 KiB
TypeScript
150 lines
4.3 KiB
TypeScript
import type {
|
|
TelegramSendDocumentParams,
|
|
TelegramSendDocumentResponse,
|
|
} from '@/tools/telegram/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const telegramSendDocumentTool: ToolConfig<
|
|
TelegramSendDocumentParams,
|
|
TelegramSendDocumentResponse
|
|
> = {
|
|
id: 'telegram_send_document',
|
|
name: 'Telegram Send Document',
|
|
description:
|
|
'Send documents (PDF, ZIP, DOC, etc.) to Telegram channels or users through the Telegram Bot API.',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
botToken: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'Your Telegram Bot API Token',
|
|
},
|
|
chatId: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Telegram chat ID (numeric, can be negative for groups)',
|
|
},
|
|
files: {
|
|
type: 'file[]',
|
|
required: false,
|
|
visibility: 'user-only',
|
|
description: 'Document file to send (PDF, ZIP, DOC, etc.). Max size: 50MB',
|
|
},
|
|
caption: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Document caption (optional)',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: '/api/tools/telegram/send-document',
|
|
method: 'POST',
|
|
headers: () => ({
|
|
'Content-Type': 'application/json',
|
|
}),
|
|
body: (params: TelegramSendDocumentParams) => {
|
|
let normalizedFiles: unknown[] | null = null
|
|
if (params.files) {
|
|
normalizedFiles = Array.isArray(params.files) ? params.files : [params.files]
|
|
}
|
|
|
|
return {
|
|
botToken: params.botToken,
|
|
chatId: params.chatId,
|
|
files: normalizedFiles,
|
|
caption: params.caption,
|
|
}
|
|
},
|
|
},
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const data = await response.json()
|
|
if (!data.success) {
|
|
throw new Error(data.error || 'Failed to send Telegram document')
|
|
}
|
|
return {
|
|
success: true,
|
|
output: data.output,
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
message: { type: 'string', description: 'Success or error message' },
|
|
files: { type: 'file[]', description: 'Files attached to the message' },
|
|
data: {
|
|
type: 'object',
|
|
description: 'Telegram message data including document',
|
|
properties: {
|
|
message_id: {
|
|
type: 'number',
|
|
description: 'Unique Telegram message identifier',
|
|
},
|
|
from: {
|
|
type: 'object',
|
|
description: 'Information about the sender',
|
|
properties: {
|
|
id: { type: 'number', description: 'Sender ID' },
|
|
is_bot: {
|
|
type: 'boolean',
|
|
description: 'Whether the chat is a bot or not',
|
|
},
|
|
first_name: {
|
|
type: 'string',
|
|
description: "Sender's first name (if available)",
|
|
},
|
|
username: {
|
|
type: 'string',
|
|
description: "Sender's username (if available)",
|
|
},
|
|
},
|
|
},
|
|
chat: {
|
|
type: 'object',
|
|
description: 'Information about the chat where message was sent',
|
|
properties: {
|
|
id: { type: 'number', description: 'Chat ID' },
|
|
first_name: {
|
|
type: 'string',
|
|
description: 'Chat first name (if private chat)',
|
|
},
|
|
username: {
|
|
type: 'string',
|
|
description: 'Chat username (for private or channels)',
|
|
},
|
|
type: {
|
|
type: 'string',
|
|
description: 'Type of chat (private, group, supergroup, or channel)',
|
|
},
|
|
},
|
|
},
|
|
date: {
|
|
type: 'number',
|
|
description: 'Unix timestamp when the message was sent',
|
|
},
|
|
document: {
|
|
type: 'object',
|
|
description: 'Document file details',
|
|
properties: {
|
|
file_name: { type: 'string', description: 'Document file name' },
|
|
mime_type: { type: 'string', description: 'Document MIME type' },
|
|
file_id: { type: 'string', description: 'Document file ID' },
|
|
file_unique_id: {
|
|
type: 'string',
|
|
description: 'Unique document file identifier',
|
|
},
|
|
file_size: {
|
|
type: 'number',
|
|
description: 'Size of document file in bytes',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|