- [Instructor] Now with my bot back to functional, I'm going to go ahead and close these tabs and go back into my terminal and I'm going to leave ngrok running. I don't want this url to change. So I'll just leave that running. But I do intend to make changes to my node code or maybe using C Sharp, doesn't matter. So I'll break this server, here and I'll start making some code changes here. So let's go to VS Code and really all I care about here is this whole dialog, which was the functionality of my previous bot.
Let's get rid of it completely. We will need a default dialog, so let's leave that line. And I will create a dialog detail over here in a moment. Now the first example that I want to show you is one-on-one conversation where you talk to the bot and the bot talks back to you, but it starts a new dialog and a new conversation. So also think of it this way, that perhaps the bot is monitoring some information and when new information arrives, it is able to talk back to a user, as in notify the user.
Well, let's see how that works. So, I do have a dialog here and I have the basic bot framework structures setup. I don't need the githubClient here so let's get rid of it. And now, let's also get rid of this file here. And now, let's go ahead and start providing some details here. So, what I want to do is that when the user says talk to me, So, I'm going to listen to a request called talk2me, again, using regex.
Then, I would like for our dialog to kick in. What do we do with this dialog? Just like before, I'm going to write a method called function (session, args, next). And here, let's go ahead and start writing the logic for talk2me. So, all I want to do is that when the user talks to me, then I want to start a new dialog with the user. So, the new dialog, let's go ahead and flush that out also.
So this a bot dot dialog and let's call this dialog 1on1dialog. And again, this'll be just function (session, args, next). That's typically the structure of a dialog. And I'm going to simply say builder dot Prompts dot text and in the current session, I'm going to say, 'Welcome, this is the start of a new dialog.' Now you may have guessed that I intend to initiate this dialog from the talk2me area.
How do we do that? Well, first I'll check, if indeed the user said talk to me. So I say, session dot message dot text dot toLowerCase should indeed be talk2me. So if indeed that is the user's intention, then we need to craft up a message. What exactly does that message look like? So, I'll set this bot dot beginDialog and it accepts two parameters.
One is the address to which you are sending this dialog to. And second, what dialog you wish to initiate. So I'll just write a variable address that I'll write up in a moment. But the dialog that I wish to initiate is 1on1Dialog. Let's make sure that these strings are identical. Now where's this address? In short, address is all the information that the bot framework needs in order to be able to communicate the message to who is this message going to.
And that simply looks like this. So we give it the channel Id of msteams. You specify the user id to whom this message is addressed so the user wasn't even logged into Microsoft Teams, they would get a notification under their activity area. And you can, in our case, just pick the user id from the incoming message. In other applications, you would save the user id's ahead of time.
You give it the tenant ID, again, you can pick that up directly from the session and then you provide the details of the bot. Give it a serviceUrl and next, useAuth: true and, bingo, your message should end up to the user. Let's test this out.
- What are bots?
- Creating bots
- Testing using ngrok
- Deploying bots to Microsoft Teams
- Testing bots
- Bots as Azure AD applications
- Updating bot registration in Azure
- Building the bot package