{"id":16431166,"url":"https://github.com/wictorwilen/botbuilder-teams-messagingextensions","last_synced_at":"2025-07-30T20:05:21.624Z","repository":{"id":34392321,"uuid":"178358289","full_name":"wictorwilen/botbuilder-teams-messagingextensions","owner":"wictorwilen","description":"Microsoft Teams Messaging Extension Middleware for Microsoft Bot Builder ","archived":false,"fork":false,"pushed_at":"2023-01-02T03:48:41.000Z","size":620,"stargazers_count":15,"open_issues_count":7,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-29T19:09:43.694Z","etag":null,"topics":["botbuilder","botbuilder-extension","botbuilder-framework","microsoft-teams","msteams"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wictorwilen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-29T07:51:09.000Z","updated_at":"2025-03-28T03:15:56.000Z","dependencies_parsed_at":"2023-01-15T06:46:42.436Z","dependency_job_id":null,"html_url":"https://github.com/wictorwilen/botbuilder-teams-messagingextensions","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/wictorwilen/botbuilder-teams-messagingextensions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wictorwilen%2Fbotbuilder-teams-messagingextensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wictorwilen%2Fbotbuilder-teams-messagingextensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wictorwilen%2Fbotbuilder-teams-messagingextensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wictorwilen%2Fbotbuilder-teams-messagingextensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wictorwilen","download_url":"https://codeload.github.com/wictorwilen/botbuilder-teams-messagingextensions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wictorwilen%2Fbotbuilder-teams-messagingextensions/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267930667,"owners_count":24167483,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["botbuilder","botbuilder-extension","botbuilder-framework","microsoft-teams","msteams"],"created_at":"2024-10-11T08:29:20.929Z","updated_at":"2025-07-30T20:05:21.553Z","avatar_url":"https://github.com/wictorwilen.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Microsoft Teams Messaging Extension Middleware for Microsoft Bot Builder\n\n[![npm version](https://badge.fury.io/js/botbuilder-teams-messagingextensions.svg)](https://badge.fury.io/js/botbuilder-teams-messagingextensions)\n\nThis middleware for [Bot Builder Framework](https://www.npmjs.com/package/botbuilder) is targeted for [Microsoft Teams](https://docs.microsoft.com/en-us/microsoftteams/platform/) based bots.\n\n | @master | @preview |\n :--------:|:---------:\n [![Build Status](https://travis-ci.org/wictorwilen/botbuilder-teams-messagingextensions.svg?branch=master)](https://travis-ci.org/wictorwilen/botbuilder-teams-messagingextensions)|[![Build Status](https://travis-ci.org/wictorwilen/botbuilder-teams-messagingextensions.svg?branch=preview)](https://travis-ci.org/wictorwilen/botbuilder-teams-messagingextensions)\n\n## About\n\nThe Microsoft Teams [Messaging Extension](https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/messaging-extensions/messaging-extensions-overview?view=msteams-client-js-latest) Middleware for Microsoft Bot Builder makes building bots for Microsoft Teams easier. By separating out the logic for Message Extensions from the implementation of the bot, you will make your code more readable and easier to debug and troubleshoot.\n\nThe middleware supports the following Message Extension features\n\n* [Message extension queries](https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/messaging-extensions/search-extensions): `composeExtension/query`\n* [Message extension settings url](https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/messaging-extensions/search-extensions#add-event-handlers): `composeExtension/querySettingUrl`\n* [Message extension settings](https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/messaging-extensions/search-extensions#add-event-handlers): `composeExtension/setting`\n* [Message extension link unfurling](https://developer.microsoft.com/en-us/office/blogs/add-rich-previews-to-messages-using-link-unfurling/): `composeExtension/queryLink`\n* [Message extension message actions](https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/messaging-extensions/create-extensions): `composeExtension/submitAction`\n* [Fetch task operations for message actions](https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/messaging-extensions/create-extensions): `composeExtension/fetchTask`\n* Adaptive Card `Action.Submit` actions: `composeExtension/onCardButtonClicked`\n* [Message extension select](https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/messaging-extensions/search-extensions): `composeExtension/selectItem`\n\n## Usage\n\nTo implement a Messaging Extension handler create a class like this:\n\n\u003e NOTE: When combining this with the `botbuilder-teams` you should avoid using the  `invokeActivityHandler.onInvoke`, as it might\n\u003e invalidate your messaging extension results.\n\n``` TypeScript\nimport { TurnContext, CardFactory, MessagingExtensionQuery, MessagingExtensionResult } from \"botbuilder\";\nimport { IMessagingExtensionMiddlewareProcessor } from \"botbuilder-teams-messagingextensions\";\n\nexport default class MyMessageExtension implements IMessagingExtensionMiddlewareProcessor {\n\n    public async onQuery(query: MessagingExtensionQuery): Promise\u003cMessagingExtensionResult\u003e {\n        const card = CardFactory.heroCard(\"Test\", \"Test\", [\"https://picsum.photos/200/200\"]);\n\n        if (query.parameters \u0026\u0026 query.parameters[0] \u0026\u0026 query.parameters[0].name === \"initialRun\") {\n            return Promise.resolve({\n                type: \"result\",\n                attachmentLayout: \"grid\",\n                attachments: [\n                    card\n                ]\n            });\n        } else {\n            return Promise.resolve({\n                type: \"result\",\n                attachmentLayout: \"list\",\n                attachments: [\n                    card\n                ]\n            });\n        }\n    }\n\n    public async onQuerySettingsUrl(): Promise\u003c{ title: string, value: string }\u003e {\n        return Promise.resolve({\n            title: \"Configuration\",\n            value: \"https://my-service-com/config.html\"\n        });\n    }\n\n    public async onSettingsUpdate(context: TurnContext): Promise\u003cvoid\u003e {\n        const setting = context.activity.value.state;\n        // Save the setting\n        return Promise.resolve();\n    }\n}\n```\n\nTo add the processor to the pipeline use code similar to this:\n\n``` TypeScript\nimport { MessagingExtensionMiddleware } from \"botbuilder-teams-messagingextensions\";\n\nconst adapter = new BotFrameworkAdapter(botSettings);\nadapter.user(new MessagingExtensionMiddleware(\"myCommandId\", new MyMessageExtension()));\n```\n\nWhere you should match the command id with the one in the Teams manifest file:\n\n``` JSON\n\"composeExtensions\": [{\n    \"botId\": \"12341234-1234-1234-123412341234\",\n    \"canUpdateConfiguration\": true,\n    \"commands\": [{\n        \"id\": \"myCommandId\",\n        \"title\": \"My Command\",\n        \"description\": \"...\",\n        \"initialRun\": true,\n        \"parameters\": [...]\n    }]\n}],\n```\n\n### Use message actions and task modules\n\nTo create an message action that shows a task module for your input define your message extension as follows in the manifest. The `fetchTask` property set to `true` indicates that we want to use a task module.\n\n``` JSON\n{\n    \"id\": \"createToDoMessageExtension\",\n    \"title\": \"Create To-Do\",\n    \"description\": \"Create a To-Do item\",\n    \"context\": [\"message\", \"commandBox\", \"compose\"],\n    \"fetchTask\": true,\n    \"type\": \"action\"\n}\n```\n\nIn the processor you need to implement the `onFetchTask` and `onSubmitAction` methods. You can either return a card using the `card` property or\nuse the `url` parameter to point to a web page.\n\n``` TypeScript\npublic async onFetchTask(context: TurnContext, value: MessagingExtensionAction): Promise\u003cMessagingExtensionResult | TaskModuleContinueResponse\u003e {\n    return Promise.resolve\u003cITaskModuleResult\u003e({\n        type: \"continue\",\n            value: {\n            title: \"Task Module\",\n            card: CardFactory.adaptiveCard({\n                $schema: \"http://adaptivecards.io/schemas/adaptive-card.json\",\n                type: \"AdaptiveCard\",\n                version: \"1.0\",\n                body: [\n                    {\n                        type: \"TextBlock\",\n                        text: \"Please enter your e-mail\"\n                    },\n                    {\n                        type: \"Input.Text\",\n                        id: \"myEmail\",\n                        placeholder: \"youremail@example.com\",\n                        style: \"email\"\n                    },\n                ],\n                actions: [\n                    {\n                        type: \"Action.Submit\",\n                        title: \"OK\",\n                        data: { id: \"unique-id\" }\n                    }\n                ]\n            })\n        }\n    });\n}\n\n// handle response in here\npublic async onSubmitAction(context: TurnContext, value: MessagingExtensionAction): Promise\u003cMessagingExtensionResult\u003e {\n   const email = value.data.myEmail;\n   const id = value.data.id;\n   ...\n}\n```\n\n## Contributors\n\n* [Wictor Wilén](https://github.com/wictorwilen) - Original author and coordinator\n* [Thomas White](https://github.com/tdwhite0)\n* [Bill Bliss](https://github.com/billbliss)\n* [greyseer256](https://github.com/greyseer256)\n* [Kavin Singh](https://github.com/kavins14)\n\n## License\n\nCopyright (c) Wictor Wilén. All rights reserved.\n\nLicensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwictorwilen%2Fbotbuilder-teams-messagingextensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwictorwilen%2Fbotbuilder-teams-messagingextensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwictorwilen%2Fbotbuilder-teams-messagingextensions/lists"}