-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Feat/telegram #314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feat/telegram #314
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f37760b
jira and confluence token refresh
00429bc
telegram message tool
1f68031
webhook configured
6ec4295
telegram requires permanent url
2a30cb7
webhook working
8a2be7e
telegram done
1ce6c9d
test
47e13b4
telegram webhook working
61a5dea
package-lock.json
5d9bfec
style curl command
18a92d4
added setWebhook logic
9535d00
added some documentation for chat ID
95c1807
styling changes
5f16aaa
added delete webhook logic
63abba8
adding docs
88268cb
updated docs for jira and telegram
6864769
added links
6f28360
moved function to other route.ts
5496183
logger
5ae2201
mrge.io changes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| --- | ||
| title: Telegram | ||
| description: Send a message through Telegram | ||
| --- | ||
|
|
||
| import { BlockInfoCard } from "@/components/ui/block-info-card" | ||
|
|
||
| <BlockInfoCard | ||
| type="telegram" | ||
| color="#E0E0E0" | ||
| icon={true} | ||
| iconSvg={`<svg className="block-icon" | ||
|
|
||
|
|
||
|
|
||
| viewBox="-5 0 41 33" | ||
| fill="none" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| > | ||
| <circle cx="16" cy="16" r="14" fill="url(#paint0_linear_87_7225)"/> | ||
| <path | ||
| d="M22.9866 10.2088C23.1112 9.40332 22.3454 8.76755 21.6292 9.082L7.36482 15.3448C6.85123 15.5703 6.8888 16.3483 7.42147 16.5179L10.3631 17.4547C10.9246 17.6335 11.5325 17.541 12.0228 17.2023L18.655 12.6203C18.855 12.4821 19.073 12.7665 18.9021 12.9426L14.1281 17.8646C13.665 18.3421 13.7569 19.1512 14.314 19.5005L19.659 22.8523C20.2585 23.2282 21.0297 22.8506 21.1418 22.1261L22.9866 10.2088Z" | ||
| fill="white"/> | ||
| <defs> | ||
| <linearGradient id="paint0_linear_87_7225" x1="16" y1="2" x2="16" y2="30" | ||
| gradientUnits="userSpaceOnUse"> | ||
| <stop stopColor="#37BBFE"/> | ||
| <stop offset="1" stopColor="#007DBB"/> | ||
| </linearGradient> | ||
| </defs> | ||
| </svg>`} | ||
| /> | ||
|
|
||
| [Telegram](https://telegram.org) is a secure, cloud-based messaging platform that enables fast and reliable communication across devices and platforms. With over 700 million monthly active users, Telegram has established itself as one of the world's leading messaging services, known for its security, speed, and powerful API capabilities. | ||
|
|
||
| <iframe width="100%" height="400" src="https://www.youtube.com/embed/nhq2Q8fndFg?start=62" title="Use Telegram with Sim Studio" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen ></iframe> | ||
|
|
||
| Telegram's Bot API provides a robust framework for creating automated messaging solutions and integrating communication features into applications. With support for rich media, inline keyboards, and custom commands, Telegram bots can facilitate sophisticated interaction patterns and automated workflows. | ||
|
|
||
| Key features of Telegram include: | ||
|
|
||
| - Secure Communication: End-to-end encryption and secure cloud storage for messages and media | ||
| - Bot Platform: Powerful bot API for creating automated messaging solutions and interactive experiences | ||
| - Rich Media Support: Send and receive messages with text formatting, images, files, and interactive elements | ||
| - Global Reach: Connect with users worldwide with support for multiple languages and platforms | ||
|
|
||
| In Sim Studio, the Telegram integration enables your agents to leverage these powerful messaging capabilities as part of their workflows. This creates opportunities for automated notifications, alerts, and interactive conversations through Telegram's secure messaging platform. The integration allows agents to send messages programmatically to individuals or channels, enabling timely communication and updates. By connecting Sim Studio with Telegram, you can build intelligent agents that engage users through a secure and widely-adopted messaging platform, perfect for delivering notifications, updates, and interactive communications. | ||
|
|
||
| ## Usage Instructions | ||
|
|
||
| Send messages to any Telegram channel using your Bot API key. Integrate automated notifications and alerts into your workflow to keep your team informed. | ||
|
|
||
|
|
||
|
|
||
| ## Tools | ||
|
|
||
| ### `telegram_message` | ||
|
|
||
| Send messages to Telegram channels or users through the Telegram Bot API. Enables direct communication and notifications with message tracking and chat confirmation. | ||
|
|
||
| #### Input | ||
|
|
||
| | Parameter | Type | Required | Description | | ||
| | --------- | ---- | -------- | ----------- | | ||
| | `botToken` | string | Yes | Your Telegram Bot API Token | | ||
| | `chatId` | string | Yes | Target Telegram chat ID | | ||
| | `text` | string | Yes | Message text to send | | ||
|
|
||
| #### Output | ||
|
|
||
| | Parameter | Type | | ||
| | --------- | ---- | | ||
| | `ok` | string | | ||
| | `date` | string | | ||
|
|
||
|
|
||
|
|
||
| ## Block Configuration | ||
|
|
||
| ### Input | ||
|
|
||
| | Parameter | Type | Required | Description | | ||
| | --------- | ---- | -------- | ----------- | | ||
| | `botToken` | string | Yes | Bot Token - Enter your Telegram Bot Token | | ||
|
|
||
|
|
||
|
|
||
| ### Outputs | ||
|
|
||
| | Output | Type | Description | | ||
| | ------ | ---- | ----------- | | ||
| | `response` | object | Output from response | | ||
| | ↳ `ok` | boolean | ok of the response | | ||
| | ↳ `result` | json | result of the response | | ||
|
|
||
|
|
||
| ## Notes | ||
|
|
||
| - Category: `tools` | ||
| - Type: `telegram` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,13 +160,70 @@ export async function DELETE( | |
| return NextResponse.json({ error: 'Unauthorized' }, { status: 403 }) | ||
| } | ||
|
|
||
| // Delete the webhook | ||
| const foundWebhook = webhooks[0].webhook | ||
|
|
||
| // If it's a Telegram webhook, delete it from Telegram first | ||
| if (foundWebhook.provider === 'telegram') { | ||
| try { | ||
| const { botToken } = foundWebhook.providerConfig as { botToken: string } | ||
|
|
||
| if (!botToken) { | ||
| logger.warn(`[${requestId}] Missing botToken for Telegram webhook deletion.`, { | ||
| webhookId: id, | ||
| }) | ||
| return NextResponse.json( | ||
| { error: 'Missing botToken for Telegram webhook deletion' }, | ||
| { status: 400 } | ||
| ) | ||
| } | ||
|
|
||
| const telegramApiUrl = `https://api.telegram.org/bot${botToken}/deleteWebhook` | ||
| const telegramResponse = await fetch(telegramApiUrl, { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| } | ||
| }) | ||
|
|
||
| const responseBody = await telegramResponse.json() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing error handling for json parsing which could throw if response is not valid JSON |
||
| if (!telegramResponse.ok || !responseBody.ok) { | ||
| const errorMessage = responseBody.description || `Failed to delete Telegram webhook. Status: ${telegramResponse.status}` | ||
| logger.error(`[${requestId}] ${errorMessage}`, { | ||
| response: responseBody | ||
| }) | ||
| return NextResponse.json( | ||
| { error: 'Failed to delete webhook from Telegram', details: errorMessage }, | ||
| { status: 500 } | ||
| ) | ||
| } | ||
|
|
||
| logger.info(`[${requestId}] Successfully deleted Telegram webhook for webhook ${id}`) | ||
| } catch (error: any) { | ||
| logger.error(`[${requestId}] Error deleting Telegram webhook`, { | ||
| webhookId: id, | ||
| error: error.message, | ||
| stack: error.stack, | ||
| }) | ||
| return NextResponse.json( | ||
| { | ||
| error: 'Failed to delete webhook from Telegram', | ||
| details: error.message | ||
| }, | ||
| { status: 500 } | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| // Delete the webhook from the database | ||
| await db.delete(webhook).where(eq(webhook.id, id)) | ||
|
|
||
| logger.info(`[${requestId}] Successfully deleted webhook: ${id}`) | ||
| return NextResponse.json({ success: true }, { status: 200 }) | ||
| } catch (error) { | ||
| logger.error(`[${requestId}] Error deleting webhook`, error) | ||
| } catch (error: any) { | ||
| logger.error(`[${requestId}] Error deleting webhook`, { | ||
| error: error.message, | ||
| stack: error.stack | ||
| }) | ||
| return NextResponse.json({ error: 'Internal server error' }, { status: 500 }) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing webhook functionality description despite PR description mentioning webhook implementation