Table Of ContentPro
Microsoft Teams
Development
A Hands-on Guide to Building Custom
Solutions for the Teams Platform
—
Rick Van Rousselt
Pro Microsoft Teams
Development
A Hands-on Guide to Building
Custom Solutions for the Teams
Platform
Rick Van Rousselt
Pro Microsoft Teams Development: A Hands-on Guide to Building Custom Solutions
for the Teams Platform
Rick Van Rousselt
Pelt, Belgium
ISBN-13 (pbk): 978-1-4842-6363-1 ISBN-13 (electronic): 978-1-4842-6364-8
https://doi.org/10.1007/978-1-4842-6364-8
Copyright © 2021 by Rick Van Rousselt
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Joan Murray
Development Editor: Laura Berendson
Coordinating Editor: Jill Balzano
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media LLC, 1 New York Plaza, Suite
4600, New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.
com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner)
is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware
corporation.
For information on translations, please e-mail [email protected]; for reprint,
paperback, or audio rights, please e-mail [email protected].
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484263631. For more
detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
For my wife Joke and my partner in crime Yves.
Table of Contents
About the Author �����������������������������������������������������������������������������������������������������xi
About the Technical Reviewers �����������������������������������������������������������������������������xiii
Acknowledgments ���������������������������������������������������������������������������������������������������xv
Introduction �����������������������������������������������������������������������������������������������������������xvii
Part 1: Before You Can Start Building ����������������������������������������������������1
Chapter 1: What’s required ���������������������������������������������������������������������������������������3
The basics �������������������������������������������������������������������������������������������������������������������������������������3
Manifest file ����������������������������������������������������������������������������������������������������������������������������������5
Your environment ��������������������������������������������������������������������������������������������������������������������������7
App Studio �������������������������������������������������������������������������������������������������������������������������������8
Sideloading ������������������������������������������������������������������������������������������������������������������������������9
Final thoughts �����������������������������������������������������������������������������������������������������������������������������11
Chapter 2: Additional tools �������������������������������������������������������������������������������������13
Additional tools on your belt �������������������������������������������������������������������������������������������������������13
ngrok �������������������������������������������������������������������������������������������������������������������������������������14
Testing ngrok �������������������������������������������������������������������������������������������������������������������������15
Linking your hard drive to Teams ������������������������������������������������������������������������������������������17
Bot Framework ����������������������������������������������������������������������������������������������������������������������19
Windows Terminal �����������������������������������������������������������������������������������������������������������������20
Summary�������������������������������������������������������������������������������������������������������������������������������������21
v
Table of ConTenTs
Chapter 3: Make it easy on yourself �����������������������������������������������������������������������23
Starting development ������������������������������������������������������������������������������������������������������������������23
Node�js setup �������������������������������������������������������������������������������������������������������������������������24
C# basic app ��������������������������������������������������������������������������������������������������������������������������36
Summary�������������������������������������������������������������������������������������������������������������������������������������46
Part 2: Tabs ������������������������������������������������������������������������������������������47
Chapter 4: Teams Client JavaScript SDK ����������������������������������������������������������������49
Background ���������������������������������������������������������������������������������������������������������������������������������49
Tabs ���������������������������������������������������������������������������������������������������������������������������������������������49
Static tab �������������������������������������������������������������������������������������������������������������������������������50
The JavaScript Client SDK �����������������������������������������������������������������������������������������������������51
C# ������������������������������������������������������������������������������������������������������������������������������������������51
Node�js �����������������������������������������������������������������������������������������������������������������������������������66
Summary�������������������������������������������������������������������������������������������������������������������������������������73
Chapter 5: Static and configurable tabs �����������������������������������������������������������������75
A web page ���������������������������������������������������������������������������������������������������������������������������������75
Types of pages �����������������������������������������������������������������������������������������������������������������������77
Feedback and Location ���������������������������������������������������������������������������������������������������������������78
C# ������������������������������������������������������������������������������������������������������������������������������������������79
Node ��������������������������������������������������������������������������������������������������������������������������������������82
C# ������������������������������������������������������������������������������������������������������������������������������������������90
Node ��������������������������������������������������������������������������������������������������������������������������������������93
Configurable tabs ������������������������������������������������������������������������������������������������������������������������96
Our company app ������������������������������������������������������������������������������������������������������������������96
The config page ���������������������������������������������������������������������������������������������������������������������97
Perspective �������������������������������������������������������������������������������������������������������������������������������110
Chapter 6: Authentication inside tabs ������������������������������������������������������������������111
Introduction �������������������������������������������������������������������������������������������������������������������������������111
Pop-up authentication ���������������������������������������������������������������������������������������������������������������115
vi
Table of ConTenTs
Silent authentication �����������������������������������������������������������������������������������������������������������������126
ADAL�js ��������������������������������������������������������������������������������������������������������������������������������127
Final thoughts ���������������������������������������������������������������������������������������������������������������������������134
Chapter 7: Integrating Teams and SharePoint ������������������������������������������������������135
Preparing our app ���������������������������������������������������������������������������������������������������������������������135
Deploying our app ���������������������������������������������������������������������������������������������������������������������136
Deploying it again ���������������������������������������������������������������������������������������������������������������������141
Final thoughts ���������������������������������������������������������������������������������������������������������������������������143
Part 3: Bots ����������������������������������������������������������������������������������������145
Chapter 8: Introducing bots ����������������������������������������������������������������������������������147
Why bots �����������������������������������������������������������������������������������������������������������������������������������147
A once-in-a-decade opportunity �����������������������������������������������������������������������������������������148
Breakdown of language ������������������������������������������������������������������������������������������������������������149
Lessons learned ������������������������������������������������������������������������������������������������������������������152
Facts ������������������������������������������������������������������������������������������������������������������������������������155
The technical side ���������������������������������������������������������������������������������������������������������������������157
Conclusion ���������������������������������������������������������������������������������������������������������������������������159
Chapter 9: Natural language processing bots ������������������������������������������������������161
Proof of concept ������������������������������������������������������������������������������������������������������������������������161
Bot 101 ��������������������������������������������������������������������������������������������������������������������������������������172
C# ����������������������������������������������������������������������������������������������������������������������������������������172
Node ������������������������������������������������������������������������������������������������������������������������������������177
Recap ����������������������������������������������������������������������������������������������������������������������������������178
Teamify our bot �������������������������������������������������������������������������������������������������������������������������178
Next steps ���������������������������������������������������������������������������������������������������������������������������������182
Summary�����������������������������������������������������������������������������������������������������������������������������������185
vii
Table of ConTenTs
Chapter 10: Activity feed bots ������������������������������������������������������������������������������187
Botify �����������������������������������������������������������������������������������������������������������������������������������������187
365 -QA ��������������������������������������������������������������������������������������������������������������������������������������195
Getting started ���������������������������������������������������������������������������������������������������������������������198
Dialogs and steps ����������������������������������������������������������������������������������������������������������������199
Summary�����������������������������������������������������������������������������������������������������������������������������������210
Chapter 11: Teams-specific bot integrations ��������������������������������������������������������211
Teams bot����������������������������������������������������������������������������������������������������������������������������������211
The right information �����������������������������������������������������������������������������������������������������������213
Sending messages ��������������������������������������������������������������������������������������������������������������216
Channels ������������������������������������������������������������������������������������������������������������������������������223
Next steps ���������������������������������������������������������������������������������������������������������������������������������227
Final thoughts ���������������������������������������������������������������������������������������������������������������������������228
Chapter 12: Calling and media bots ���������������������������������������������������������������������229
Change of scenery ��������������������������������������������������������������������������������������������������������������������229
Microsoft Graph ������������������������������������������������������������������������������������������������������������������������231
Service-hosted ��������������������������������������������������������������������������������������������������������������������������233
Breaking it down �����������������������������������������������������������������������������������������������������������������237
Summary�����������������������������������������������������������������������������������������������������������������������������������240
Part 4: Webhooks �������������������������������������������������������������������������������241
Chapter 13: Incoming webhooks ��������������������������������������������������������������������������243
Webhooks ���������������������������������������������������������������������������������������������������������������������������������243
Breakdown ��������������������������������������������������������������������������������������������������������������������������244
Posting information �������������������������������������������������������������������������������������������������������������������249
Cards �����������������������������������������������������������������������������������������������������������������������������������251
Summary�����������������������������������������������������������������������������������������������������������������������������������274
Chapter 14: Outgoing webhooks ��������������������������������������������������������������������������275
Breakdown ��������������������������������������������������������������������������������������������������������������������������������275
C# ����������������������������������������������������������������������������������������������������������������������������������������276
viii
Table of ConTenTs
Node ������������������������������������������������������������������������������������������������������������������������������������276
Webhook creation ����������������������������������������������������������������������������������������������������������������277
C# ����������������������������������������������������������������������������������������������������������������������������������������281
Node ������������������������������������������������������������������������������������������������������������������������������������282
Summary�����������������������������������������������������������������������������������������������������������������������������������283
Part 5: Messaging Extensions �����������������������������������������������������������285
Chapter 15: Search-based extensions ������������������������������������������������������������������287
Location, location, location �������������������������������������������������������������������������������������������������������287
Manifest ������������������������������������������������������������������������������������������������������������������������������������289
Time to code ������������������������������������������������������������������������������������������������������������������������292
Settings �������������������������������������������������������������������������������������������������������������������������������298
Summary�����������������������������������������������������������������������������������������������������������������������������������306
Chapter 16: Action-based extensions �������������������������������������������������������������������307
Differences ��������������������������������������������������������������������������������������������������������������������������������307
Task modules �����������������������������������������������������������������������������������������������������������������������309
Static action-based extension ��������������������������������������������������������������������������������������������������309
Embedded web view �����������������������������������������������������������������������������������������������������������������319
Adaptive cards ��������������������������������������������������������������������������������������������������������������������������330
Link unfurling ����������������������������������������������������������������������������������������������������������������������������337
Summary�����������������������������������������������������������������������������������������������������������������������������������341
Part 6: Developing Against Microsoft Teams �������������������������������������343
Chapter 17: Microsoft Graph for Teams ����������������������������������������������������������������345
Background �������������������������������������������������������������������������������������������������������������������������������345
Permissions ������������������������������������������������������������������������������������������������������������������������������346
Tokens ���������������������������������������������������������������������������������������������������������������������������������347
Getting information ��������������������������������������������������������������������������������������������������������������350
Tooling ���������������������������������������������������������������������������������������������������������������������������������351
Summary�����������������������������������������������������������������������������������������������������������������������������������353
ix
Table of ConTenTs
Chapter 18: PowerShell for Teams �����������������������������������������������������������������������355
Getting started ��������������������������������������������������������������������������������������������������������������������������355
Other ways ��������������������������������������������������������������������������������������������������������������������������������359
Summary�����������������������������������������������������������������������������������������������������������������������������������360
Appendix A: Advanced Teams development ���������������������������������������������������������361
CI and CD ����������������������������������������������������������������������������������������������������������������������������������361
Source control ���������������������������������������������������������������������������������������������������������������������362
Pipeline ��������������������������������������������������������������������������������������������������������������������������������365
Protected APIs ���������������������������������������������������������������������������������������������������������������������������372
PowerApps in Teams �����������������������������������������������������������������������������������������������������������������372
Summary�����������������������������������������������������������������������������������������������������������������������������������373
Appendix B: Add your solution to the Teams app store ����������������������������������������375
C ompany �����������������������������������������������������������������������������������������������������������������������������������375
Submission ��������������������������������������������������������������������������������������������������������������������������376
Review ���������������������������������������������������������������������������������������������������������������������������������379
Summary�����������������������������������������������������������������������������������������������������������������������������������383
Index ���������������������������������������������������������������������������������������������������������������������385
x