Book Image

Building Bots with Microsoft Bot Framework

By : Kishore Gaddam
Book Image

Building Bots with Microsoft Bot Framework

By: Kishore Gaddam

Overview of this book

Bots help users to use the language as a UI and interact with the applications from any platform. This book teaches you how to develop real-world bots using Microsoft Bot Framework. The book starts with setting up the Microsoft Bot Framework development environment and emulator, and moves on to building the first bot using Connector and Builder SDK. Explore how to register, connect, test, and publish your bot to the Slack, Skype, and Facebook Messenger platforms. Throughout this book, you will build different types of bots from simple to complex, such as a weather bot, a natural speech and intent processing bot, an Interactive Voice Response (IVR) bot for a bank, a facial expression recognition bot, and more from scratch. These bots were designed and developed to teach you concepts such as text detection, implementing LUIS dialogs, Cortana Intelligence Services, third-party authentication, Rich Text format, Bot State Service, and microServices so you can practice working with the standard development tools such as Visual Studio, Bot Emulator, and Azure.
Table of Contents (10 chapters)

Messages

Your bot can send rich text, emoticons, pictures, and cards to a user or group. Users can send rich text and pictures to your bot. You can specify the type of content your bot can handle in the Skype settings page for your bot:

Content From user to bot From bot to user Description
Rich text Including emoticons :)
Pictures PNG, JPEG, or GIF up to 20 Mb
Video Coming soon MP4, AAC+h264 up to 15 Mb (approx. 1 minute), plus JPEG thumbnail
Cards

Basic format

Each Skype user is assigned a unique ID for your bot, which is sent along with the display name with every message:

{ 
"text": "Hello (wave)",
"id": "1466182688092",
"type": "message/text",
"timestamp": "2016-06-17T16:58:08.74Z",
"channelId": "skype",
"serviceUrl": "https://apis.skype.com",
"from": {
"id": "29:2hJJkjmGn4ljB2X7YYEju-sgFwgvnISvE6G3abGde8ts",
"name": "Display Name"
},
"conversation": {
"id": "29:2hJJkjmGn4ljB2X7YYEju-sgFwgvnISvE6G3abGde8ts"
},
"recipient": {
"id": "28:29415286-5a43-4a00-9dc5-bcbc2ce1f59e",
"name": "Trivia Master"
}
}

The from field contains the unique user ID (prefixed by 29) and user Display Name. The recipient field contains the app ID (prefixed by 28, which indicates a bot in Skype) and the bot's display name. In Skype, your bot is addressed using the Bot Framework App ID (a GUID).

You cannot currently use slash (/) commands as part of conversations with your bot. This is a reserved character in Skype.

Rich text

Users can communicate with the bot using rich text format as well. Users can make the chat text as bold if needed or a bot can communicate with the user and make certain words as bold. Most of the channels support all the text properties supported by the Microsoft Bot Framework.

Skype emoticons

Skype emoticons can be sent by using the emoticon keyword in parentheses:

{
"text": "(heart)"
}

The output of the preceding code is as follows:

If a user sends your bot an emoticon, it may include <ss> tags around the emoticon, which can be ignored; for example, <ss type="skype">(wave)</ss>. Sending Skype Mojis (short, expressive video clips) is not currently supported.

Welcome messages

To send a welcome message to a user, listen for the contactRelationUpdate activity. To send a welcome message to a group, listen for the conversationUpdate activity.

Pictures and videos

Let's check out, how pictures and videos are sent:

  • Pictures and videos are sent by adding attachments to a message
  • Pictures can be PNG, JPEG, or GIF up to 20 Mb
  • Videos can be MP4 or AAC+h264 up to 15 Mb (approx. 1 minute), plus JPEG thumbnails