-
Notifications
You must be signed in to change notification settings - Fork 29
Update quoted replies & new quotes features #482
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
Open
corinagum
wants to merge
12
commits into
main
Choose a base branch
from
cg/quoted-replies
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4758273
Remove withReplyToId
67ca7d3
Quotes replies feature
eb33aa5
Quoted replies sample
e635d31
Mark as experimental in docs and remove replyToId changes in reply
17d2d0c
Fix binding to rest.activity
026faf4
Update examples
e73214c
Update package-lock
1036764
Apply Copilot feedback?
2cfd08d
Add JSDoc for time field format (IC3 epoch)
b80fb34
reply defer to quoteReply
ec39830
Move stamping to model layer
62a7a48
update to quote and verbiage improvements
corinagum 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| teams*.yml | ||
| env/ | ||
| infra/ | ||
| node_modules/ | ||
| .vscode/ | ||
| dist/ | ||
| .env |
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,30 @@ | ||
| # Example: Quoted Replies | ||
|
|
||
| A bot that demonstrates quoted reply features in Microsoft Teams — referencing previous messages when sending responses. | ||
|
|
||
| ## Commands | ||
|
|
||
| | Command | Behavior | | ||
| |---------|----------| | ||
| | `test reply` | `reply()` — auto-quotes the inbound message | | ||
| | `test quote` | `quote()` — sends a message, then quotes it by ID | | ||
| | `test add` | `addQuote()` — sends a message, then quotes it with builder + response | | ||
| | `test multi` | Sends two messages, then quotes both with interleaved responses | | ||
| | `test manual` | `addQuote()` + `addText()` — manual control | | ||
| | `help` | Shows available commands | | ||
| | *(quote a message)* | Bot reads and displays the quoted reply metadata | | ||
|
|
||
| ## Run | ||
|
|
||
| ```bash | ||
| npm run dev | ||
| ``` | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| Create a `.env` file: | ||
|
|
||
| ``` | ||
| CLIENT_ID=<your-azure-bot-app-id> | ||
| CLIENT_SECRET=<your-azure-bot-app-secret> | ||
| ``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,51 @@ | ||
| { | ||
| "$schema": "https://developer.microsoft.com/json-schemas/teams/v1.20/MicrosoftTeams.schema.json", | ||
| "version": "1.0.0", | ||
| "manifestVersion": "1.20", | ||
| "id": "${{TEAMS_APP_ID}}", | ||
| "name": { | ||
| "short": "quoted-replies", | ||
| "full": "Quoted Replies Example" | ||
| }, | ||
| "developer": { | ||
| "name": "Microsoft", | ||
| "mpnId": "", | ||
| "websiteUrl": "https://microsoft.com", | ||
| "privacyUrl": "https://privacy.microsoft.com/privacystatement", | ||
| "termsOfUseUrl": "https://www.microsoft.com/legal/terms-of-use" | ||
| }, | ||
| "description": { | ||
| "short": "Bot demonstrating quoted replies", | ||
| "full": "A sample bot that demonstrates how to send and receive quoted replies in Microsoft Teams." | ||
| }, | ||
| "icons": { | ||
| "outline": "outline.png", | ||
| "color": "color.png" | ||
| }, | ||
| "accentColor": "#FFFFFF", | ||
| "staticTabs": [ | ||
| { | ||
| "entityId": "conversations", | ||
| "scopes": ["personal"] | ||
| }, | ||
| { | ||
| "entityId": "about", | ||
| "scopes": ["personal"] | ||
| } | ||
| ], | ||
| "bots": [ | ||
| { | ||
| "botId": "${{BOT_ID}}", | ||
| "scopes": ["personal", "team", "groupChat"], | ||
| "isNotificationOnly": false, | ||
| "supportsCalling": false, | ||
| "supportsVideo": false, | ||
| "supportsFiles": false | ||
| } | ||
| ], | ||
| "validDomains": ["${{BOT_DOMAIN}}", "*.botframework.com"], | ||
| "webApplicationInfo": { | ||
| "id": "${{BOT_ID}}", | ||
| "resource": "api://botid-${{BOT_ID}}" | ||
| } | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
| module.exports = require('@microsoft/teams.config/eslint.config').default; |
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,35 @@ | ||
| { | ||
| "name": "@examples/quoted-replies", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "license": "MIT", | ||
| "main": "dist/index", | ||
| "types": "dist/index", | ||
| "files": [ | ||
| "dist", | ||
| "README.md" | ||
| ], | ||
| "scripts": { | ||
| "clean": "npx rimraf ./dist", | ||
| "lint": "npx eslint", | ||
| "lint:fix": "npx eslint --fix", | ||
| "build": "npx tsc", | ||
| "start": "node .", | ||
| "dev": "tsx watch -r dotenv/config src/index.ts" | ||
| }, | ||
| "dependencies": { | ||
| "@microsoft/teams.api": "*", | ||
| "@microsoft/teams.apps": "*", | ||
| "@microsoft/teams.cards": "*", | ||
| "@microsoft/teams.common": "*", | ||
| "@microsoft/teams.dev": "*" | ||
| }, | ||
| "devDependencies": { | ||
| "@microsoft/teams.config": "*", | ||
| "@types/node": "^22.5.4", | ||
| "dotenv": "^16.4.5", | ||
| "rimraf": "^6.0.1", | ||
| "tsx": "^4.20.6", | ||
| "typescript": "^5.4.5" | ||
| } | ||
| } |
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,115 @@ | ||
| import { MessageActivity } from '@microsoft/teams.api'; | ||
| import { App } from '@microsoft/teams.apps'; | ||
| import { ConsoleLogger } from '@microsoft/teams.common/logging'; | ||
| import { DevtoolsPlugin } from '@microsoft/teams.dev'; | ||
|
|
||
| const app = new App({ | ||
| logger: new ConsoleLogger('@examples/quoted-replies', { level: 'debug' }), | ||
| plugins: [new DevtoolsPlugin()], | ||
| }); | ||
|
|
||
| app.on('message', async ({ send, reply, quote, activity }) => { | ||
| await reply({ type: 'typing' }); | ||
|
|
||
| const text = activity.text?.toLowerCase() || ''; | ||
|
|
||
| // ============================================ | ||
| // Read inbound quoted replies | ||
| // ============================================ | ||
| const quotes = activity.getQuotedMessages(); | ||
| if (quotes.length > 0) { | ||
| const quote = quotes[0].quotedReply; | ||
| const info = [ | ||
| `Quoted message ID: ${quote.messageId}`, | ||
| quote.senderName ? `From: ${quote.senderName}` : null, | ||
| quote.preview ? `Preview: "${quote.preview}"` : null, | ||
| quote.isReplyDeleted ? '(deleted)' : null, | ||
| quote.validatedMessageReference ? '(validated)' : null, | ||
| ].filter(Boolean).join('\n'); | ||
|
|
||
| await send(`You sent a message with a quoted reply:\n\n${info}`); | ||
| } | ||
|
|
||
| // ============================================ | ||
| // reply() — auto-quotes the inbound message | ||
| // ============================================ | ||
| if (text.includes('test reply')) { | ||
| await reply('Thanks for your message! This reply auto-quotes it using reply().'); | ||
| return; | ||
| } | ||
|
|
||
| // ============================================ | ||
| // quote() — quote a previously sent message by ID | ||
| // ============================================ | ||
| if (text.includes('test quote')) { | ||
| const sent = await send('The meeting has been moved to 3 PM tomorrow.'); | ||
| await quote(sent.id, 'Just to confirm — does the new time work for everyone?'); | ||
| return; | ||
| } | ||
|
|
||
| // ============================================ | ||
| // addQuote() — builder with response | ||
| // ============================================ | ||
| if (text.includes('test add')) { | ||
| const sent = await send('Please review the latest PR before end of day.'); | ||
| const msg = new MessageActivity() | ||
| .addQuote(sent.id, 'Done! Left my comments on the PR.'); | ||
| await send(msg); | ||
| return; | ||
| } | ||
|
|
||
| // ============================================ | ||
| // Multi-quote with mixed responses | ||
| // ============================================ | ||
| if (text.includes('test multi')) { | ||
| const sentA = await send('We need to update the API docs before launch.'); | ||
| const sentB = await send('The design mockups are ready for review.'); | ||
| const sentC = await send('CI pipeline is green on main.'); | ||
| const msg = new MessageActivity() | ||
| .addQuote(sentA.id, 'I can take the docs — will have a draft by Thursday.') | ||
| .addQuote(sentB.id, 'Looks great, approved!') | ||
| .addQuote(sentC.id); | ||
| await send(msg); | ||
| return; | ||
| } | ||
|
|
||
| // ============================================ | ||
| // addQuote() + addText() — manual control | ||
| // ============================================ | ||
| if (text.includes('test manual')) { | ||
| const sent = await send('Deployment to staging is complete.'); | ||
| const msg = new MessageActivity() | ||
| .addQuote(sent.id) | ||
| .addText(' Verified — all smoke tests passing.'); | ||
| await send(msg); | ||
| return; | ||
| } | ||
|
|
||
| // ============================================ | ||
| // Help / Default | ||
| // ============================================ | ||
| if (text.includes('help')) { | ||
| await reply( | ||
| '**Quoted Replies Test Bot**\n\n' + | ||
| '**Commands:**\n' + | ||
| '- `test reply` - reply() auto-quotes your message\n' + | ||
| '- `test quote` - quote() quotes a previously sent message\n' + | ||
| '- `test add` - addQuote() builder with response\n' + | ||
| '- `test multi` - Multi-quote with mixed responses (one bare quote with no response)\n' + | ||
| '- `test manual` - addQuote() + addText() manual control\n\n' + | ||
| 'Quote any message to me to see the parsed metadata!' | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| await reply('Say "help" for available commands.'); | ||
| }); | ||
|
|
||
| app.on('install.add', async ({ send }) => { | ||
| await send( | ||
| 'Hi! I demonstrate quoted replies.\n\n' + | ||
| 'Say **help** to see available commands.' | ||
| ); | ||
| }); | ||
|
|
||
| app.start().catch(console.error); |
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,8 @@ | ||
| { | ||
| "extends": "@microsoft/teams.config/tsconfig.node.json", | ||
| "compilerOptions": { | ||
| "outDir": "dist", | ||
| "rootDir": "src" | ||
| }, | ||
| "include": ["src/**/*.ts"] | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.
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.