OfficeDev: Introducing Office365 Bot your office 365 assistant is here --Part 2
On office365
In this part we will go through building the bot itself. Firstly, we need to register the bot visit http://dev.botframework.com , sign in using your Microsoft account and register your bot
don’t worry your bot
won’t be visible to others as long you decide not to.
There is two ways to integrate our bot with Luis model we built in the part 1. Either create our own Luis.ai
consumer which will basically execute GET calls to the Luis.ai application
passing along the client chat message/utterance as a query, or the easy way which use LuisDialog. In this particular walk-through we will use the
LuisDialog which comes along with the botbuilder npm package.
- First let's create a new folder
- Let’s initialize a new nodejs app using npm init , fill the required data
- Now our nodejs application is ready we can run it using node server.js, however up till this moment it basically does nothing, let’s install the needed npm packages for us which are:
- adal-node (to access the Office365 resources using client credentials “no user context required”)
- botbuilder(built by Microsoft to accelerate building bots)
- node-cache(used to cache the access token)
- restify (RESTful server for incoming user requests (chat messages)
- Let’s create new file and choose a creative name for it LuisConstants.js! this file will store all the Luis and bot related constants:
- url Luis app url
- appID bot ID
- appSecret botAppSecret
- we need another file to store our O365 configuration constants:
- authority url http://login.windows.net
- tenant add your tenant ID here (either GUID or full qualified name)
- client ID your Azure AD app
- client secret needed to perform login
- resource https://graph.microsoft.com
- bookMeetingurl contains hardcoded graph url to a specific user event calendar https://graph.microsoft.com/v1.0/users/{user_email_here}/calendar/events
- In our server.js which is generated by initializing node app we add the necessary required modules
- Now let’s create a new BotConnector bot using the registered bot Id and secret andcreate a new Luis.ai dialog
- Let’s default our luis dialog the to process all incoming requests, you can have different luis dialog handles different types of request for simplicity we will use single dialog to handle all the incoming requests
- Let’s add a default handler for the unknown utterances which our luis model will eventually fail to understand
- And a handler for welcome intent
- Let's add our main intent handler which will execute a POST request to user's calendar event to create a meeting invite.
The conversation will appear like the below snapshot
the code is available via this link
No Comment to " OfficeDev: Introducing Office365 Bot your office 365 assistant is here --Part 2 "