-
Notifications
You must be signed in to change notification settings - Fork 3.3k
feat(webhooks): ms teams webhook #740
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
Changes from all commits
Commits
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
130 changes: 130 additions & 0 deletions
130
...low-block/components/sub-block/components/webhook/components/providers/microsoftteams.tsx
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,130 @@ | ||
| import { Shield, Terminal } from 'lucide-react' | ||
| import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert' | ||
| import { CodeBlock } from '@/components/ui/code-block' | ||
| import { Input } from '@/components/ui/input' | ||
| import { ConfigField } from '../ui/config-field' | ||
| import { ConfigSection } from '../ui/config-section' | ||
| import { InstructionsSection } from '../ui/instructions-section' | ||
| import { TestResultDisplay } from '../ui/test-result' | ||
|
|
||
| interface MicrosoftTeamsConfigProps { | ||
| hmacSecret: string | ||
| setHmacSecret: (secret: string) => void | ||
| isLoadingToken: boolean | ||
| testResult: { | ||
| success: boolean | ||
| message?: string | ||
| test?: any | ||
|
Contributor
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. style: test prop has type 'any'. Consider defining a specific type for test results |
||
| } | null | ||
| copied: string | null | ||
| copyToClipboard: (text: string, type: string) => void | ||
| testWebhook: () => Promise<void> | ||
| } | ||
|
|
||
| const teamsWebhookExample = JSON.stringify( | ||
| { | ||
| type: 'message', | ||
| id: '1234567890', | ||
| timestamp: '2023-01-01T00:00:00.000Z', | ||
| localTimestamp: '2023-01-01T00:00:00.000Z', | ||
| serviceUrl: 'https://smba.trafficmanager.net/amer/', | ||
| channelId: 'msteams', | ||
| from: { | ||
| id: '29:1234567890abcdef', | ||
| name: 'John Doe', | ||
| }, | ||
| conversation: { | ||
| id: '19:meeting_abcdef@thread.v2', | ||
| }, | ||
| text: 'Hello Sim Studio Bot!', | ||
| }, | ||
| null, | ||
| 2 | ||
| ) | ||
icecrasher321 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export function MicrosoftTeamsConfig({ | ||
| hmacSecret, | ||
| setHmacSecret, | ||
| isLoadingToken, | ||
| testResult, | ||
| copied, | ||
| copyToClipboard, | ||
| testWebhook, | ||
| }: MicrosoftTeamsConfigProps) { | ||
| return ( | ||
| <div className='space-y-4'> | ||
| <ConfigSection title='Microsoft Teams Configuration'> | ||
| <ConfigField | ||
| id='teams-hmac-secret' | ||
| label='HMAC Secret' | ||
| description='The security token provided by Teams when creating an outgoing webhook. Used to verify request authenticity.' | ||
| > | ||
| <Input | ||
| id='teams-hmac-secret' | ||
| value={hmacSecret} | ||
| onChange={(e) => setHmacSecret(e.target.value)} | ||
| placeholder='Enter HMAC secret from Teams' | ||
| disabled={isLoadingToken} | ||
| type='password' | ||
| /> | ||
| </ConfigField> | ||
| </ConfigSection> | ||
|
|
||
| <TestResultDisplay | ||
| testResult={testResult} | ||
| copied={copied} | ||
| copyToClipboard={copyToClipboard} | ||
| showCurlCommand={true} | ||
| /> | ||
|
|
||
| <InstructionsSection | ||
| title='Setting up Outgoing Webhook in Microsoft Teams' | ||
| tip='Create an outgoing webhook in Teams to receive messages from Teams in Sim Studio.' | ||
| > | ||
| <ol className='list-inside list-decimal space-y-1'> | ||
| <li>Open Microsoft Teams and go to the team where you want to add the webhook.</li> | ||
| <li>Click the three dots (•••) next to the team name and select "Manage team".</li> | ||
| <li>Go to the "Apps" tab and click "Create an outgoing webhook".</li> | ||
| <li>Provide a name, description, and optionally a profile picture.</li> | ||
| <li>Set the callback URL to your Sim Studio webhook URL (shown above).</li> | ||
| <li>Copy the HMAC security token and paste it into the "HMAC Secret" field above.</li> | ||
| <li>Click "Create" to finish setup.</li> | ||
| </ol> | ||
| </InstructionsSection> | ||
|
|
||
| <InstructionsSection title='Receiving Messages from Teams'> | ||
| <p> | ||
| When users mention your webhook in Teams (using @mention), Teams will send a POST request | ||
| to your Sim Studio webhook URL with a payload like this: | ||
| </p> | ||
| <CodeBlock language='json' code={teamsWebhookExample} className='mt-2 text-sm' /> | ||
| <ul className='mt-3 list-outside list-disc space-y-1 pl-4'> | ||
| <li>Messages are triggered by @mentioning the webhook name in Teams.</li> | ||
| <li>Requests include HMAC signature for authentication.</li> | ||
| <li>You have 5 seconds to respond to the webhook request.</li> | ||
| </ul> | ||
| </InstructionsSection> | ||
|
|
||
| <Alert> | ||
| <Shield className='h-4 w-4' /> | ||
| <AlertTitle>Security</AlertTitle> | ||
| <AlertDescription> | ||
| The HMAC secret is used to verify that requests are actually coming from Microsoft Teams. | ||
| Keep it secure and never share it publicly. | ||
| </AlertDescription> | ||
| </Alert> | ||
|
|
||
| <Alert> | ||
| <Terminal className='h-4 w-4' /> | ||
| <AlertTitle>Requirements</AlertTitle> | ||
| <AlertDescription> | ||
| <ul className='mt-1 list-outside list-disc space-y-1 pl-4'> | ||
| <li>Your Sim Studio webhook URL must use HTTPS and be publicly accessible.</li> | ||
| <li>Self-signed SSL certificates are not supported by Microsoft Teams.</li> | ||
| <li>For local testing, use a tunneling service like ngrok or Cloudflare Tunnel.</li> | ||
| </ul> | ||
| </AlertDescription> | ||
| </Alert> | ||
| </div> | ||
| ) | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.