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.

  1. First let's create a new folder
  2. Let’s initialize a new nodejs app using npm init , fill the required data
  3. 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)
  4. 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
  5. 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
  6. In our server.js which is generated by initializing node app we add the necessary required modules
  7. Now let’s create a new BotConnector bot using the registered bot Id and secret andcreate a new Luis.ai dialog
  8.   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
  9. Let’s add a default handler for the unknown utterances which our luis model will eventually fail to understand
  10. And a handler for welcome intent
  11. Let's add our main intent handler which will execute a POST request to user's calendar event to create a meeting invite.
As we can see it's a waterfall of functions and you can move next and back to validate and prompt user for more missing information , for simplicity we only capture two entities (name and time) I don't try to validate the user as a contact and search for the user within my contact list.

The conversation will appear like the below snapshot


and the bot will be able to create  a meeting invite using Microsoft Graph Calendar endpoint
the code is available via this link