{"id":16431178,"url":"https://github.com/wictorwilen/express-msteams-host","last_synced_at":"2025-03-21T04:32:00.785Z","repository":{"id":37430903,"uuid":"142681087","full_name":"wictorwilen/express-msteams-host","owner":"wictorwilen","description":"Express utility for Microsoft Teams solutions","archived":false,"fork":false,"pushed_at":"2023-01-24T09:18:23.000Z","size":1274,"stargazers_count":14,"open_issues_count":10,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T20:56:11.026Z","etag":null,"topics":["decorators","express","express-router","expressjs","hacktoberfest","microsoft-teams","microsoftteams","nodejs","typescript"],"latest_commit_sha":null,"homepage":"","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":"2018-07-28T13:52:02.000Z","updated_at":"2024-12-16T03:55:50.000Z","dependencies_parsed_at":"2023-02-13T19:47:51.514Z","dependency_job_id":null,"html_url":"https://github.com/wictorwilen/express-msteams-host","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wictorwilen%2Fexpress-msteams-host","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wictorwilen%2Fexpress-msteams-host/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wictorwilen%2Fexpress-msteams-host/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wictorwilen%2Fexpress-msteams-host/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wictorwilen","download_url":"https://codeload.github.com/wictorwilen/express-msteams-host/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244738403,"owners_count":20501842,"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","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":["decorators","express","express-router","expressjs","hacktoberfest","microsoft-teams","microsoftteams","nodejs","typescript"],"created_at":"2024-10-11T08:29:23.483Z","updated_at":"2025-03-21T04:32:00.487Z","avatar_url":"https://github.com/wictorwilen.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Express utility for Microsoft Teams Apps\n\n[![npm version](https://badge.fury.io/js/express-msteams-host.svg)](https://www.npmjs.com/package/express-msteams-host)\n[![npm](https://img.shields.io/npm/dt/express-msteams-host.svg)](https://www.npmjs.com/package/express-msteams-host)\n[![MIT](https://img.shields.io/npm/l/express-msteams-host.svg)](https://github.com/wictorwilen/express-msteams-host/blob/master/LICENSE.md)\n[![GitHub issues](https://img.shields.io/github/issues/wictorwilen/express-msteams-host.svg)](https://github.com/wictorwilen/express-msteams-host/issues)\n[![GitHub closed issues](https://img.shields.io/github/issues-closed/wictorwilen/express-msteams-host.svg)](https://github.com/wictorwilen/express-msteams-host/issues?q=is%3Aissue+is%3Aclosed)\n\nThis utility for [Express](https://expressjs.com/) is targeted for [Microsoft Teams](https://docs.microsoft.com/en-us/microsoftteams/platform/) applications built generated by the [Microsoft Teams Yeoman generator](https://aka.ms/yoteams) hosted on Express.\n\n | @master | @preview |\n :--------:|:---------:\n [![Build Status](https://travis-ci.org/wictorwilen/express-msteams-host.svg?branch=master)](https://travis-ci.org/wictorwilen/express-msteams-host)|[![Build Status](https://travis-ci.org/wictorwilen/express-msteams-host.svg?branch=preview)](https://travis-ci.org/wictorwilen/express-msteams-host)\n\nThe Middleware serves two major purposes:\n\n* Automatic routing of web services for Bots, Connectors and Outgoing Webhooks based on TypeScript decorators\n* Automatic routing of static pages for Tabs and Connectors\n\nThe middleware is automatically added to projects generated by the Microsoft Teams Yeoman generator.\n\n## Usage\n\nFor the automatic routing to work the following usage MUST be followed.\n\n### Creating a bot\n\n### Implementation and decorator usage for Bots\n\nBots MUST be implemented as a class extending the `TeamsActivityHandler` class and decorated using the `BotDeclaration` decorator.\n\n``` TypeScript\nimport { BotDeclaration } from 'express-msteams-host';\nimport { MemoryStorage, ConversationState, TurnContext, TeamsActivityHandler, BotFrameworkAdapter } from 'botbuilder';\n\n@BotDeclaration(\n    '/api/messages',\n    new MemoryStorage(),\n    process.env.MICROSOFT_APP_ID,\n    process.env.MICROSOFT_APP_PASSWORD)\nexport class myBot extends TeamsActivityHandler {\n\n    public constructor(conversationState: ConversationState, private adapter: BotFrameworkAdapter) {\n        super();\n        ...\n        this.onMessage(async (context: TurnContext): Promise\u003cvoid\u003e =\u003e {\n           ...\n        });\n        ...\n    }\n\n}\n```\n\n### Adding support for Calling in bots\n\n\u003e **NOTE:** This method is deprecated and might be deleted in the future. For now it will remain available for usage.\n\nWhen adding calling support to bots you need to create an incoming webhook method of your bot implementation. This method should be decorated with the `BotCallingWebhook` decorator and must follow the [Express middleware signature](http://expressjs.com/en/4x/api.html#middleware-callback-function-examples). The endpoint you specify in the decorator, has to represent the calling endpoint you specify when registering the Teams Channel to your Bot in the Azure portal.\n\n``` TypeScript\nimport { BotDeclaration, BotCallingWebhook } from 'express-msteams-host';\nimport express = require(\"express\");\n\n@BotDeclaration(...)\nexport class myBot extends TeamsActivityHandler {\n\n    @BotCallingWebhook(\"/api/calling\")\n    public async onIcomingCall(req: express.Request, res: express.Response, next: express.NextFunction) {\n        ...\n    }\n}\n```\n\n### Decorators for Message Extensions\n\nMessage Extensions is implemented using the Bot Builder middleware [botbuilder-teams-messagingextensions](https://github.com/wictorwilen/botbuilder-teams-messagingextensions) and when referenced in the bot implementation decorated with the `MessageExtensionDeclarator` decorator. The `express-msteams-host` will automatically hook up the correct messaging extensions with the correct bot.\n\nIn the implementation of the bot, define the message extensions as below. You are responsible for instantiating the object, you might want to add additional parameters or configuration.\n\n``` TypeScript\nimport { BotDeclaration } from 'express-msteams-host';\nimport { MemoryStorage, ConversationState, TurnContext, TeamsActivityHandler, BotFrameworkAdapter } from 'botbuilder';\nimport { MyMessageExtension } from './MyMessageExtension';\nimport { TeamsAdapter } from \"botbuilder-teams\";\n\n@BotDeclaration(\n    '/api/messages',\n    new MemoryStorage()\n    process.env.MICROSOFT_APP_ID,\n    process.env.MICROSOFT_APP_PASSWORD)\nexport class myBot extends TeamsActivityHandler {\n\n    @MessageExtensionDeclaration('myMessageExtension')\n    private _myMessageExtension: MyMessageExtension;\n\n    public constructor(private conversationState: ConversationState, private adapter: BotFrameworkAdapter) {\n        super();\n        ...\n        this._myMessageExtension = new MyMessageExtension();\n        ...\n    }\n\n}\n```\n\n### Decorator for Connectors\n\nConnectors MUST be implemented as a class implementing the `IConnector` interface and decorated using the `ConnectorDeclaration` decorator.\n\n``` TypeScript\nimport { ConnectorDeclaration, IConnector } from 'express-msteams-host';\nimport { Request } from \"express\";\n\n@ConnectorDeclaration(\n    '/api/connector/connect',\n    '/api/connector/ping',\n)\nexport class myConnector implements IConnector {\n    Connect(req: Request): void {\n        ...\n    }\n\n    Ping(req: Request): Promise\u003cvoid\u003e[] {\n        ...\n    }\n}\n```\n\n### Decorator for Outgoing Webhooks\n\nOutgoing Webhooks MUST be implemented as a class implementing the `IOutgoingWebhook` interface and decorated using the `OutgoingWebhookDeclaration` decorator.\n\n``` TypeScript\nimport { OutgoingWebhookDeclaration, IOutgoingWebhook } from 'express-msteams-host';\nimport * as express from 'express';\n\n@OutgoingWebhookDeclaration('/api/webhook')\nexport class myOutgoingWebhook implements IOutgoingWebhook {\n    public requestHandler(req: Express.Request, res: Express.Response, next: Express.NextFunction): any {\n        ...\n    }\n}\n```\n\n### Preventing pages to be iframed in other applications than Microsoft Teams\n\nBy using the `PreventIframe` decorator on server side classes pages can be declared to include a CSP that prohibts the pages from being\niframed into other applications than Microsoft Teams.\n\n``` TypeScript\nimport { PreventIframe } from \"express-msteams-host\";\n\n@PreventIframe(\"/page/index.html\")\nexport class MyPage {\n    ...\n}\n```\n\n## Logging\n\nTo enable logging from this module you need to add `msteams` to the `DEBUG` environment variable. See the [debug package](https://www.npmjs.com/package/debug) for more information.\n\nExample for Windows command line:\n\n\u003e SET DEBUG=msteams\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%2Fexpress-msteams-host","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwictorwilen%2Fexpress-msteams-host","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwictorwilen%2Fexpress-msteams-host/lists"}