From the course: Microsoft Teams Bot Development

User profile Teams Bot

From the course: Microsoft Teams Bot Development

User profile Teams Bot

- [Instructor] When using the bot framework with Microsoft Teams, there are a number of possibilities. Let me show you a few more. Another interesting thing you can do is use a method called fetchMembers that'll allow you to get things like your profile. Let's see how that works. At this point my bot is working and grock is listening. Just like before it controls the node js server because we're going to make some code changes here. Go back into your project and you know this dialog that we had, talk2me? Go in and empty it out. We're going to replace this logic. So starting anything between this function, go ahead and remove it. Also we won't be starting a new dialog here, we'll just do everything we need to right inside this dialog so let's go ahead and remove the one on one new dialog as well. Okay let's go ahead go ahead and replace this talk2me with aboutme so the bot should tell me a little bit about me, the user that is talking to the bot. How do we do that? Well this is a method called fetchMembers. So I'm going to say, connector.fetchMembers. And here I'm going to say session.message.address.serviceUrl and where are we trying to get messages from? Well in the current conversation, so that will be just one user, that is me. You could test this bot in a group setting as well. Like if multiple users are having a many to one chat with the bot. But right now we're in a one to one chat. So I'll just say session.message.address. Now I need the conversation ID, and you can just simply pick it up like this. Okay so give it the conversation ID. Now I should get either an error or a result. An arrow function syntax. If is an error, well we still want to tell the user that the error occurred but basically we want to end the dialog. So we'll say session.endDialog, and here I'll simply say JSON.stringify(err). What if there is success? Else session, we really don't have much to do after this particular method has successfully completed so I'll just say endDialog, and again JSON.stringify, but this time I'll send back the result, that's it. There's one other line of code that I need to mention down here, which is, I'll say bot.use(new buildertTeams.StringBotAtMentions()). The reason I'm doing this is because here I intend to act mention the bot and say act mention aboutme. So I can say at my custom bot aboutme. So I'm sort of invoking the bot. And the message that I'm checking for is just aboutme, I don't want the act custom bot name to appear in that chatting, so I'm simply saying StripBotAtMentions, great. Let's go ahead and pass this bot.

Contents