page_type | description | products | languages | extensions | urlFragment | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
Sample that shows how to use dialog bot with bot sdk v4, messaging extension and facebook auth flow in Nodejs. |
|
|
|
officedev-microsoft-teams-samples-app-complete-sample-nodejs |
Sample that shows how to use dialog bot with bot sdk v4, messaging extension, facebook auth flow in Nodejs.
Please find below demo manifest which is deployed on Microsoft Azure and you can try it yourself by uploading the app package (.zip file link below) to your teams and/or as a personal app. (Sideloading must be enabled for your tenant, see steps here).
Microsoft Teams Bot: Manifest
-
Register a new application in the Azure Active Directory – App Registrations portal.
-
Register a bot with Azure Bot Service, following the instructions here.
- Ensure that you've enabled the Teams Channel
- While registering the bot, use
https://<your_ngrok_url>/api/messages
as the messaging endpoint.
- To test facebook auth flow [create a facebookapp](https://docs.microsoft.com/azure/bot-service/bot-service-channel-connect-facebook?view=azure-bot-service- 4.0) and get client id and secret for facebook app. Now go to your bot channel registartion -> configuration -> Add OAuth connection string
- Provide connection Name : for eg
facebookconnection
- Select service provider ad
facebook
- Add clientid and secret of your facebook app that was created using Step 9.
Open the ".env" file in the project and add connection name which we have provided in bot channel registration E.g. ConnectionName = facebookconnection
-
Setup NGROK
- Run ngrok - point to port 3978
# ngrok http -host-header=rewrite 3978
-
Clone the repository
git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
-
In a terminal, navigate to
samples/app-complete-sample/nodejs
-
Once you have saved your bot and gotten the confirmation that it is created, navigate back to your project. Open the ".env" file. There, copy/paste your App ID and App password from the step above.
MicrosoftAppId= MicrosoftAppPassword= BaseUri=https://#####abc.ngrok.io
-
Install modules
npm install
-
Run your bot at the command line:
npm start
- Setup Manifest for Teams
-
This step is specific to Teams.
- Edit the
manifest.json
contained in the ./AppPackage or ./Manifest_hub folder folder to replace your Microsoft App Id (that was created when you registered your app registration earlier) everywhere you see the place holder string{{Microsoft-App-Id}}
(depending on the scenario the Microsoft App Id may occur multiple times in themanifest.json
) - Edit the
manifest.json
forvalidDomains
and replace{{domain-name}}
with base Url of your domain. E.g. if you are using ngrok it would behttps://1234.ngrok.io
then your domain-name will be1234.ngrok.io
. - Zip up the contents of the
AppPackage
orManifest_hub
folder to create amanifest.zip
(Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package)
Note: If you want to test your app across multi hub like: Outlook/Office.com, please update the
manifest.json
in the/Manifest_Hub
folder with the required values. - Edit the
-
Upload the manifest.zip to Teams (in the Apps view click "Upload a custom app")
- Go to Microsoft Teams. From the lower left corner, select Apps
- From the lower left corner, choose Upload a custom App
- Go to your project directory, the ./AppPackage folder, select the zip folder, and choose Open.
- Select Add in the pop-up dialog box. Your app is uploaded to Teams.
Note: If you are facing any issue in your app, please uncomment this line and put your debugger for local debug.
This project is meant to help a Teams developer in two ways. First, it is meant to show many examples of how an app can integrate into Teams. Second, it is meant to give a set of patterns, templates, and tools that can be used as a starting point for creating a larger, scalable, more enterprise level bot to work within Teams. Although this project focuses on creating a robust bot, it does include simples examples of tabs as well as examples of how a bot can give links into these tabs.
At a high level, this project is written in TypeScript, built to run a Node server, uses Gulp to run its build steps, runs a TypeScript linting tool to keep the code uniform, and uses the BotFramework to handle the bot's requests and responses. This project is designed to be run in VSCode using its debugger in order to leverage breakpoints in TypeScript. Most directories will hold a README file which will describe what the files within that directory do.
The easiest way to get started is to follow the steps listed in the "Steps to get started running the Bot Emulator". Once this is complete and running, the easiest way to add your own content is to create a new dialog in src/dialogs by copying one from src/dialogs/examples, change it accordingly, and then instantiate it with the others in the RootDialog.ts.
-
manifest
This directory holds the skeleton of a manifest.json file that can be altered in order sideload this application into a team. -
public and views
This directory holds static html, image, and javascript files used by the tabs and bot. This is not the only public directory that is used for the tabs, though. This directory holds the html and javascript used for the configuration page of the configurable tab. The main content of the static and configurable tabs is created dynamically by the code in src/tab/TabSetup.ts or comes from the static files placed in build/src/public/exampleDialogs, which are created at build time based upon the TypeScript dialogs in src/dialogs/examples. -
src
This directory holds all of the TypeScript files, which run the entire application. These files, at build, are transpiled and their transpiled javascript files are placed in the build directory.
-
To view your app in Outlook on the web.
-
Go to Outlook on the weband sign in using your dev tenant account.
On the side bar, select More Apps. Your sideloaded app title appears among your installed apps
Select your app icon to launch and preview your app running in Outlook on the web
Select your app icon from message extension and find ward, it will show all options
Note: Similarly, you can test your application in the Outlook desktop app as well.
-
To preview your app running in Office on the web.
-
Log into office.com with test tenant credentials
Select the Apps icon on the side bar. Your sideloaded app title appears among your installed apps
Select your app icon to launch your app in Office on the web
Note: Similarly, you can test your application in the Office 365 desktop app as well.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.