This blog is about SharePoint, Office365 and Office Development

Popular Posts

OfficeDev: Introducing Office365 Bot your office 365 assistant is here --Part 3


In the previous posts we saw how to create a bot using botframework and integrate it to LUIS platform to process the textual user input and generate user intents and entities which are more likely to be understood by our application then normal text.

In  this post we will integrate our Office365 assistant bot into Skype bot in a simple configuration steps. we do not need to rewrite any of the code we've already have before. In a similar manner our bot can be connected to other various bots.

Creating a Skype bot
without digging into further details about Skype bot , you  can find a lot of details here , the most important step is when creating a bot under messaging webhook make sure you got the URL copied from your generic bot

Use the below URL and place your bot Id as query string parameter
https://skype.botframework.com/Dev/?botId={Your bot ID here} for example using our previous bot example we can use

https://skype.botframework.com/Dev/?botId=EmailAssistantDemo

Testing our bot in Skype
after creating the bot you will find a button that suggest adding the bot as Skype contact it will redirect to a URL

https://join.skype.com/bot/{your_bot_id}


After adding the bot as Skype contact we can find it online as in the below image


As we can see the Email assistant bot is not available for messaging, so let's start our bot locally

In the generic bot definition we need to publish accessible URL we can easily deploy our bot to azure website or simply use a tool like ngrok to tunnel connection to our localhost


now a *.ngrok.io link will be generated so let's substitute end point with this new value and let's add /api/messages as a suffix.



now let's really test our bot integration with Skype

Connected bots vs. Specific platform bots

Building bots as connected bot not vs. building  a platform specific bot is basically depends on your bot scenario for example connected bots are good if you don't require a specific requirement based on the bot conversation context and you would like to share the same behavior between different bots. However having the conversation context of the bot is a good advantage so we can deliver a tailored experience based on user behavior which depends on the platform capabilities.

OfficeDev: Introducing Office365 Bot your office 365 assistant is here --Part 2


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