Skip to content
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

[Multi Hub] Tab Calander- Nodejs Sample #837

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/build-complete-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,14 @@ jobs:
- project_path: 'samples/meetings-app-icon-badging/nodejs'
name: 'meetings-app-icon-badging'
version: '18.x'

- project_path: 'samples/tab-calendar/ts/api-server'
name: 'tab-calendar-api-server'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to create deploy pipeline.

version: '18.x'

- project_path: 'samples/tab-calendar/ts'
name: 'tab-calendar'
version: '18.x'

fail-fast: false
name: Build all "${{ matrix.name }}" nodejs
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The [Teams Toolkit](https://marketplace.visualstudio.com/items?itemName=TeamsDev
|20| Tab app monetization | This sample shows how to open purchase dialog and trigger purchase flow using teams-js sdk. ||[View][tab-app-monetization#nodejs]|
|21| Personal Tab with Nav-Bar menu | Add multiple actions to the upper right in Nav-Bar and build an overflow menu for extra actions in an app. ||[View][tab-navbar-menu#ts]|
|22| App Caching in Meetings | This sample shows how to improve the subsequent loading time of an App. |||[View][app-cache-meetings#nodejs]|
|23| Personal Tab with Nav-Bar menu | Add multiple actions to the upper right in Nav-Bar and build an overflow menu for extra actions in an app. ||[View][tab-navbar-menu#ts]|
|23| Tab Calendar in Outlook | Interact with the user's calendar, including opening calendar items and composing meetings.||[View][tab-calendar#ts]|
ChetanSharma-msft marked this conversation as resolved.
Show resolved Hide resolved

## [Bots samples](https://docs.microsoft.com/microsoftteams/platform/bots/what-are-bots) (using the v4 SDK)
>NOTE:
Expand Down Expand Up @@ -238,6 +238,7 @@ The [Teams Toolkit](https://marketplace.visualstudio.com/items?itemName=TeamsDev
[tab-request-approval#nodejs]:samples/tab-request-approval/nodejs
[bot-request-approval#nodejs]:samples/bot-request-approval/nodejs
[tab-navbar-menu#ts]:samples/tab-navbar-menu/ts
[tab-calendar#ts]:samples/tab-calendar/ts

[group-channel-tab#cs#razor]:samples/tab-channel-group/razor-csharp
[group-channel-tab#cs#mvc]:samples/tab-channel-group/mvc-csharp
Expand Down
6 changes: 6 additions & 0 deletions samples/tab-calendar/ts/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
HTTPS=false
BROWSER=none
PORT=3978
REACT_APP_AZURE_APP_REGISTRATION_ID="{{REACT_APP_AZURE_APP_REGISTRATION_ID}}"
REACT_APP_BASE_URL="{{REACT_APP_BASE_URL}}"
REACT_APP_GRAPH_SCOPES=User.Read
24 changes: 24 additions & 0 deletions samples/tab-calendar/ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.eslintcache

npm-debug.log*
yarn-debug.log*
yarn-error.log*
Binary file added samples/tab-calendar/ts/Images/AppOutlook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/tab-calendar/ts/Images/ClickView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/tab-calendar/ts/Images/HomeScreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/tab-calendar/ts/Images/Install.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/tab-calendar/ts/Manifest/color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions samples/tab-calendar/ts/Manifest/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.16/MicrosoftTeams.schema.json",
"manifestVersion": "1.16",
"version": "1.0.0",
"id": "{{Microsoft-App-Id}}",
"packageName": "com.teams.TabCalendar",
ChetanSharma-msft marked this conversation as resolved.
Show resolved Hide resolved
"developer": {
"name": "Microsoft",
"websiteUrl": "https://www.microsoft.com",
"privacyUrl": "https://www.teams.com/privacy",
"termsOfUseUrl": "https://www.teams.com/termsofuser"
},
"icons": {
"color": "color.png",
"outline": "outline.png"
},
"name": {
"short": "Tab Calendar",
"full": "Tab Calendar"
},
"description": {
"short": "Short description for Tab Calendar",
ChetanSharma-msft marked this conversation as resolved.
Show resolved Hide resolved
"full": "Full description of Interact with the user's calendar, including opening calendar items and composing meetings."
ChetanSharma-msft marked this conversation as resolved.
Show resolved Hide resolved
},
"accentColor": "#5558AF",
"staticTabs": [
{
"contentUrl": "https://{{domain-name}}/tab",
"websiteUrl": "https://{{domain-name}}/tab",
"entityId": "com.contoso.TabCalendar.help",
ChetanSharma-msft marked this conversation as resolved.
Show resolved Hide resolved
"name": "TabCalendar",
"scopes": [
"personal"
]
}
],
"permissions": [
"identity",
"messageTeamMembers"
],
"validDomains": [
"{{domain-name}}"
],
"webApplicationInfo": {
"id": "{{Microsoft-App-Id}}",
"resource": "api://{{domain-name}}/{{Microsoft-App-Id}}"
}
}
Binary file added samples/tab-calendar/ts/Manifest/outline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
161 changes: 161 additions & 0 deletions samples/tab-calendar/ts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
---
page_type: sample
description: This sample shows tab calendar in Outlook apps.
ChetanSharma-msft marked this conversation as resolved.
Show resolved Hide resolved
products:
- office-teams
- office
- office-365
languages:
- typescript
extensions:
contentType: samples
createdDate: "20/06/2023 01:38:27 PM"
urlFragment: officedev-microsoft-teams-samples-tab-calendar-ts
---

# Tab Calendar in Outlook
ChetanSharma-msft marked this conversation as resolved.
Show resolved Hide resolved

Interact with the user's calendar, including opening calendar items and composing meetings.
ChetanSharma-msft marked this conversation as resolved.
Show resolved Hide resolved

## Included Features
* Tabs
ChetanSharma-msft marked this conversation as resolved.
Show resolved Hide resolved

## Interaction with app

![Tab Personal QuickstartGif](Images/TabcalendarGif.gif)

## Prerequisites
- [NodeJS](https://nodejs.org/en/)

- [M365 developer account](https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/build-and-test/prepare-your-o365-tenant) or access to a Teams account with the appropriate permissions to install an app.
- [Ngrok](https://ngrok.com/download) (For local environment testing) Latest (any other tunneling software can also be used)

- [Teams](https://teams.microsoft.com) Microsoft Teams is installed and you have an account

## Register you app with Azure AD

1. Register a new application in the [Azure Active Directory – App Registrations](https://go.microsoft.com/fwlink/?linkid=2083908) portal.
2. Select **New Registration** and on the *register an application page*, set following values:
* Set **name** to your app name.
* Choose the **supported account types** (any account type will work)
* Leave **Redirect URI** empty.
* Choose **Register**.
3. On the overview page, copy and save the **Application (client) ID, Directory (tenant) ID**. You’ll need those later when updating your Teams application manifest and in the .env.
4. Under **Manage**, select **Expose an API**.
5. Select the **Set** link to generate the Application ID URI in the form of `api://{base-url}/{AppID}`. Insert your fully qualified domain name (with a forward slash "/" appended to the end) between the double forward slashes and the GUID. The entire ID should have the form of: `api://fully-qualified-domain-name/{AppID}`
* ex: `api://%ngrokDomain%.ngrok-free.app/00000000-0000-0000-0000-000000000000`.
6. Select the **Add a scope** button. In the panel that opens, enter `access_as_user` as the **Scope name**.
7. Set **Who can consent?** to `Admins and users`
8. Fill in the fields for configuring the admin and user consent prompts with values that are appropriate for the `access_as_user` scope:
* **Admin consent title:** Teams can access the user’s profile.
* **Admin consent description**: Allows Teams to call the app’s web APIs as the current user.
* **User consent title**: Teams can access the user profile and make requests on the user's behalf.
* **User consent description:** Enable Teams to call this app’s APIs with the same rights as the user.
9. Ensure that **State** is set to **Enabled**
10. Select **Add scope**
* The domain part of the **Scope name** displayed just below the text field should automatically match the **Application ID** URI set in the previous step, with `/access_as_user` appended to the end:
* `api://[ngrokDomain].ngrok-free.app/00000000-0000-0000-0000-000000000000/access_as_user.
11. In the **Authorized client applications** section, identify the applications that you want to authorize for your app’s web application. Each of the following IDs needs to be entered:
* `4765445b-32c6-49b0-83e6-1d93765276ca` (Office web)
* `0ec893e0-5785-4de6-99da-4ed124e5296c` (Office desktop)
* `bc59ab01-8403-45c6-8796-ac3ef710b3e3` (Outlook web)
* `d3590ed6-52b3-4102-aeff-aad2292ab01c` (Outlook desktop)
12. Navigate to **API Permissions**, and make sure to add the follow permissions:
- Select Add a permission
-  Select Microsoft Graph -\> Delegated permissions.
- `User.Read` (enabled by default)
- `Calendars.Read`
- `Calendars.ReadBasic`
- `Calendars.ReadWrite`
- Click on Add permissions. Please make sure to grant the admin consent for the required permissions.
13. Navigate to **Authentication**
If an app hasn't been granted IT admin consent, users will have to provide consent the first time they use an app.
- Set a redirect URI:
* Select **Add a platform**.
* Select **Single-page application**.
* Enter the **redirect URI** for the app in the following format: `https://{Base_Url}/auth-end`.
14. Navigate to the **Certificates & secrets**. In the Client secrets section, click on "+ New client secret". Add a description(Name of the secret) for the secret and select “Never” for Expires. Click "Add". Once the client secret is created, copy its value, it need to be placed in the .env.

2. Setup NGROK
- Run ngrok - point to port 3978

```bash
ngrok http 3978 --host-header="localhost:3978"
```
3. Setup for code
Clone the repository

```bash
git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
```

4. Open .env file from this path folder `samples/tab-calendar/ts/api-server` and update
- `{{CLIENT_ID}}` - Generated from Step 1 (Application (client) ID)is the application app id
- `{{CLIENT_SECRET}}` - Generated from Step 1.14, also referred to as Client secret

5. Open .env file from this path folder `samples/tab-calendar/ts` and update
- `{{REACT_APP_AZURE_APP_REGISTRATION_ID}}` - Generated from Step 1 (Application (client) ID)is the application app id
- `{{REACT_APP_BASE_URL}}` - Your application's base url. E.g. https://12345.ngrok-free.app if you are using ngrok.

6. We have two different solutions to run, so follow below steps:

- In a terminal, navigate to `samples/tab-calendar/ts/api-server` folder, Open your local terminal and run the below command to install node modules. You can do the same in Visual studio code terminal by opening the project in Visual studio code

```bash
npm install
```

```bash
npm start
```
- The server will start running on 5000 port

- In a different terminal, navigate to `samples/tab-calendar/ts` folder, Open your local terminal and run the below command to install node modules. You can do the same in Visual studio code terminal by opening the project in Visual studio code

```bash
npm install
```

```bash
npm start
```
- The client will start running on 3978 port

4. Setup Manifest for Teams

ChetanSharma-msft marked this conversation as resolved.
Show resolved Hide resolved
- **This step is specific to Teams.**
**Edit** the `manifest.json` contained in the `Manifest/` folder to replace with your MicrosoftAppId (that was created in step1.1 and is the same value of MicrosoftAppId in `.env` file) *everywhere* you see the place holder string `{{Microsoft-App-Id}}` (depending on the scenario the Microsoft App Id may occur multiple times in the `manifest.json`)
**Edit** the `manifest.json` for `validDomains` and replace `{{domain-name}}` with base Url of your domain. E.g. if you are using ngrok it would be `https://1234.ngrok-free.app` then your domain-name will be `1234.ngrok-free.app`.
**Zip** up the contents of the `Manifest/` folder to create a `manifest.zip` or `Manifest_Hub/` folder to create a `manifest_Hub.zip`
**Upload** the `manifest.zip` to Teams (in the left-bottom *Apps* view, click "Upload a custom app")

## Running the sample

**Install App:**

![InstallApp](Images/Install.png)

**On the side bar, select More Apps. Your sideloaded app title appears among your installed apps:**

![AppOutlook](Images/AppOutlook.png)

**Select your app icon to launch and preview your app running in Outlook on the desktop:**

![HomeScreen](Images/HomeScreen.png)

**Add Details for Compose Meeting:**

![EnterComposeMeeting](Images/EnterComposeMeeting.png)

**Click ComposeMeeting:**

![ClickComposeMeeting](Images/ClickComposeMeeting.png)

**Click View:**

![ClickView](Images/ClickView.png)

## Further Reading.
[Calendar Module](https://learn.microsoft.com/en-us/javascript/api/@microsoft/teams-js/calendar?view=msteams-client-js-latest)
ChetanSharma-msft marked this conversation as resolved.
Show resolved Hide resolved

<img src="https://pnptelemetry.azurewebsites.net/microsoft-teams-samples/samples/tab-calendar-ts" />
3 changes: 3 additions & 0 deletions samples/tab-calendar/ts/api-server/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CLIENT_ID="{{CLIENT_ID}}"
CLIENT_SECRET="{{CLIENT_SECRET}}"
GRAPH_SCOPES=User.Read
14 changes: 14 additions & 0 deletions samples/tab-calendar/ts/api-server/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const esbuild = require('esbuild');
esbuild.build({
entryPoints: ['server.js'],
bundle: true,
platform: 'node',
outfile: 'dist/index.js'
})
.then((r) => {
console.log(`Build succeeded.`);
})
.catch((e) => {
console.log("Error building:", e.message);
process.exit(1);
});
Loading