>> You're not going to want to miss
this episode of The AI Show where
we take Bot Framework and Teams,
put them together and it's pretty awesome. Make sure you tune in.
[MUSIC].
>> Hello and welcome to this episode of
The AI Show where we're going to talk a little bit about bots,
so I got a special guest. Tell us who you are and what you do.
>> Yeah, I'm Gary Pretty. I'm a senior engineer
on the Bot Framework SDK Team.
>> So when I think of bots,
I basically live in Teams and I'm like,
bots and Teams obviously worked together
since the beginning, but now there's new stuff.
Tell us about what's been
there the whole time and then what's the next.
>> Yes. So you've always been able to build a chatbot for
Teams just like you can build it for any of
the other channels like Facebook or WebChat,
etc, but what we really wanted to do as
an SDK Team is make
the developer experience for Teams
as awesome as it possibly could be.
So the Team's Team who had already
done some work to actually build some and
Custom NuGet Packages to make
the developer experience straightforward as possible,
got together with the Bot Framework SDK Team
and the two Teams have worked incredibly
closely together to make Teams of
first-class citizen inside the Bot Framework SDK.
So there's now no separate packages to
download as long as you're using the Bot Framework SDK,
you've also got the extra bits that you need to
build awesome experiences for Teams as well.
>> I see. Before, it was like
a connector, before it was a separate thing?
>> Yeah, they were separate packages
and you would have to develop the legwork yourself.
So Teams will send a lot of
custom events to the bot depending on what happens.
So if somebody joins a channel or somebody sends a message,
then events will get sent to your bot,
but previously you had to really manipulate those events yourself,
and we tried to abstract as much of that away as possible
and just make it super easy to build these experiences.
>> For those that have never seen
a bot actually work in Teams, do you have something to shows us?
>> Yeah, sure. So this is
just a really simple example that I've
actually pulled straight from our samples repository.
It's a very basic example where I've got a welcome card here,
like an adaptive card or Hero card I can share in Teams.
So if I click "Update Card",
that's going to call out to the bot and the bot's going
to go ahead and update that card for me.
I could say things like MentioneMe.
If I do that, the bot's going to take
that event and it's going to say, "Hello Gary Pretty."
So you can see here that you've got
the basic foundations of building a conversational chatbot.
So I could send normal text
backwards and forwards but we can be more
interactive using these hooks.
The way that that works, if I jump over to
Visual Studio and we look at the code behind this,
it's all centered around this Teams activity handler.
So people who build bots regularly will know that we have
a basic activity handler which will handle things
like normal messages being received.
So as you can see here,
this methods, if the message comes in, it says,
"MentionMe", I'm going to call
the MentionActivityAsync method and
it's going to do what we just saw in the example.
The great thing about the Teams Activity handler is that it
extends the number of
methods that you can use to be ready Team specific.
So as an example here,
if somebody was to join the conversation,
then I actually just get
a list of people who've been added to that conversation.
I get the information about the Team right there.
I don't need to do any parsing of the incoming event,
it's just done for me,
and I can send a message back.
So previously there would have been
a lot more code for you to actually go and pass yourself.
Another example that I dropped in
here is on MessageReactionActivityAsync.
So if somebody does a thumbs-up on a message,
then we can just send them a message and say,
"Hey, thanks for the reaction."
So if I go back to Teams,
I do a thumbs up on the previous message,
the bot's going to come back and say,
"Hey, thanks for the reaction."
So you get some really fantastic abilities
to build those traditional
conversational experiences out of the box.
>> That's cool. So as I'm looking at this screen right here,
is this a conversation that you've
started with the bot and that others can join?
>> So right now I'm having a conversation with the bot,
but the bot doesn't just
have to work in a one-to-one conversation.
The bot can actually be added to a channel.
So I can be having a conversation
with different team members and then I could
@thebot and ask the bot something and actually it
could help us along in our conversation.
>> I see. So you could literally make
a digital assistant in Teams, you're like, "Hey, where I"m I?
Where's the team going to be over the next couple of weeks?"
If I can do stuff like that.
Hook it up to O365 or stuff like that.
>> Well, it's interesting because we've
got something called the Virtual Assistant
Project which provides you with an enterprise class best practice,
but with capabilities like a calendar,
O365 to do integration.
Actually you can take that and add that into Teams and use
that day-to-day in Teams to book your meetings, read your e-mails.
It's really really clever stuff.
>> So speaking of samples,
you mentioned a sample which is it open source,
is it something I can build in,
are there other examples of things that I can do?
>> Yeah, sure. If we just jump over here,
the bot builder samples repository,
so github.com/Microsoft/BotBuilder- Samples.
We've got a ton of samples in here that
we work really hard to maintain and keep up-to-date.
As part of those samples,
we have specific examples around Teams.
The samples I'm showing here are the.NET Core Samples,
but we also have the same samples in JavaScript and also
we have two other SDKs for Python and Java as well.
>> Well, that's fantastic. So the one that you were actually
showing here was one of these samples?
>> That's right. Yes, so anybody can go to the Samples Repository,
clone the Repo and within
a few minutes they can be up and running with the bot in Teams.
So it comes with the Team's app manifest that you
need to actually install the App into Teams.
It's got all of the instructions there and
it literally takes a few minutes to get going.
The nice thing about the samples is if you're working on a bot,
we try and keep the samples as small and focused as
possible so that you can actually just jump in,
find the code that you need.
Maybe for example, I'll show you in a minute,
a Teams Messaging Extension.
You can grab the code that you need and you're on your way.
>> Well, let's talk about these extensions.
So you said Teams Messaging Extensions and I was like,
"Okay, what is that and how do I do it. "
>> So the best thing to do is probably show you an example of one.
So Team supports a few different App types
and Messaging Extensions is one of them.
Specifically, I'm going to show you a search Messaging Extension.
So the example and again this is part of our samples repository,
so you can go and get up and running with this straight away,
is this NuGet Search Extension.
>> Let's pause right here because I'm looking at this.
When you put @NuGet.
That is calling an Extension.
>> So yes, that's right. So we've installed
a Team's App which surfaces this NuGET Search Extension for me.
>> I see. So the Team's App that you're
installing is going to have Extensions as well as bot interaction.
>> So you can have an App that's a bot,
you can have an App that's a
TeamsMessagingExtension.search or you can
have an action-based search extensions.
Loads of different things that you can do with bots in time.
Hence why we have the several different examples
to show you how you can get going.
>> It makes sense.
>> To show you what we can do here,
let's imagine I'm having a conversation with
another developer on my Team and they say to me,
"Hey, which NuGet's package should
I use for this particular scenario?"
So right here I've add to
the search extension and I've now got the search box.
I could have done that up here in the Search Window as well.
If I now just do BotBuilder,
that's going to go away and actually do
a search of NuGet packages and it could be anything.
I can then pick one of those NuGet packages that's
then going to add a card for
that NuGet package into the Messaging Window,
and I can actually just send that.
The bot's brought the Welcome Card because with
the default behavior in our sample is
just to show you
the Welcome Card if it doesn't understand what you're
saying just so you get an idea of how these things work.
What I think is really important to take away
from this is previously
it would have taken
potentially hundreds of lines of
code to write something like this.
You can see that experience is really nice.
We're using all the richness that's in Teams,
but we want to make sure it's as easy as
possible to actually build that experience.
If we jump over back to Visual Studio
and we a have a look at the code behind it,
it's just two methods.
So we've got Method 1,
which is OnTeamsMessagingExtensionQueryAsync.
So every time I type into that search box,
as I'm typing, it's sending a query into this method.
This method will do the NuGET search and then simply
create a list of previewCards
which are the ones that we saw in the list,
and a list of cards that should be added to
the Chat Window if I select one.
The second method is
the MessagingExtensionsSelectItemAsync and all that it's
doing is taking the JSON from the card that
we created before and putting that in the Messaging Window.
So you're talking maybe,
50 lines of code all up to build that awesome experience.
>> Yeah, but some of them aren't even like real lines of code.
It's like we've been doing up stuff.
>> Exactly. It's building out attachments.
The nice thing about it is none of this is you trying
to manipulate Teams because we're doing that for you.
>> So there's been a lot of concepts thrown at us.
You talked about messaging extensions,
you talked about bots and Teams.
Are they separate things?
It looks like you're building it all in the same place.
>> So the common way to do
it is if you want to build a Messaging extension
you would install that as a Team's App.
That's going to be backed by a bot.
If you want them to have a conversational bot,
you'll have a separate App and that's going to be backed by a bot.
So you know how I said @NuGet Search Extension, that's one bar.
Where I said, I was having a conversation before,
it's called TeamsConversationBot, if you switch back over.
So I could add TeamsConversationBot if I wanted too as well.
>> I see.
>> The nice thing about it is
these things can be surfaced all over Teams,
but I'm really just scratching the surface
because we can do things like notifications.
When we're in Visual Studio,
if we actually switch back over to the ConversationBot,
if I show you the different methods I can override,
then you can see the number of
different events that we can actually get.
So when members are added,
when members are removed,
when we receive a reaction,
when a channel name changes,
when someone's added to a channel,
when the bot joins a conversation,
we can actually react to all of those events.
It really allows you to
really light up that whole experience in Teams.
We just want to get out of your way.
We want to allow you to call out to those third-party services,
call out to O365.
Really do whatever you want
to provide for your customers and your users.
We don't want you to be really worried about having to
interpret all of those events
that are coming backwards and focus on Teams.
>> I see. So basically you can install Apps that can be bought.
You can create a number of different functionalities backed
by the Bot Framework and
do a number of different things collaboratively.
>> Exactly, yeah.
>> This has been an amazing, thanks so much.
>> Thank you.
>> Thank you again for watching.
We've been learning all about how to use the Bot Framework in
Teams and all the new functionality that's in there.
Thank you so much for watching,
we'll see you next time. Take care.
[MUSIC]