Chatbot Development using Bot Framework Composer
Bot Framework Composer | AI chatbot development | Article on bot development
In this article we are going to see how to create a chatbot using Bot Framework Composer and Microsoft Azure AI tools like LUIS.
Prerequisites:
- Bot Framework Composer
- Azure Subscription.
- Basic Knowledge of natural language AI LUIS (Language understanding intelligent service).
After installing Bot Framework Composer open it and it will look like below image:
What you can do with Composer
Composer is a visual editing canvas for building bots. With Composer, you can:
- Create a new bot using a template, which incorporates the Virtual Assistant capabilities directly into Composer.
- Add natural language understanding capabilities to your Bot using LUIS and QnA and FAQ capabilities using QnA Maker.
- Author text and if needed speech variation responses for your Bot using language generation templates.
- Author bots in multiple languages.
- Test directly inside Composer using embedded Web Chat.
- Publish bots to Azure App Service and Azure Functions.
- Extend Power Virtual Agents with Composer (Preview).
- Integrate external services such as QnA Maker knowledge base.
Beyond a visual editing canvas, you can use Composer to do the following:
Import and export dialog assets to share with other developers.
- Package manager provides a range of reusable conversational assets and code built by Microsoft and third parties. These assets can quickly add functionality to your project.
- Make any Bot available as a Skill for other Bots to call.
- Connect to a skill.
- Extend the dialog authoring canvas with Create custom actions.
- Integrate Orchestrator, which is an advanced transformer model-based router that can delegate from a parent bot to skills based on a user's utterance.
- Host Composer in the cloud.
- Extend Composer with plugins.
Adaptive dialogs
Dialogs provide a way for bots to manage conversations with users. Adaptive dialogs and the event model simplify sophisticated conversation modeling enabling more natural, dynamic conversation flow, interruption, and context switching. They also help you focus on the model of the conversation rather than the mechanics of dialog management. Read more in the dialog concept article.
Language understanding
Language understanding is a core component of Composer that allows developers and conversation designers to train language understanding models directly in the context of editing a dialog. As dialogs are edited in Composer, developers can continuously add to their bots' natural language capabilities using the .lu file format, a simple Markdown-like format that makes it easy to define new intents and entities, and provide sample utterances. In Composer, you can use regular expression, LUIS, and Orchestrator recognizers. Composer detects changes and updates the bot's cloud-based natural language understanding model automatically so it's always up to date. Read more in the language understanding concept article.
Language generation
Creating grammatically correct, data-driven responses that have a consistent tone and convey a clear brand voice has always been a challenge for bot developers. Composer's integrated bot response generation allows developers to create bot replies with a great deal of flexibility, using the editor in the Bot Responses page or the response editor in the Properties pane. Read more in the language generation concept article.
With Language Generation, you can achieve previously complex tasks easily such as:
- Including dynamic elements in messages.
- Generating grammatically correct lists, pronouns, articles.
- Providing context-sensitive variation in messages.
- Creating Adaptive Cards attachments, as seen above.
- Provide speech variations for each response, including Speech Synthesis Markup Language (SSML) modifications, which are key for speech-based experiences such as telephony.
QnA Maker
QnA Maker is a cloud-based service that enables you to extract question-and-answer pairs from existing FAQ-style documents and websites into a knowledge base that can be manually curated by knowledge experts. QnA Maker, once integrated into a bot, can be used to find the most appropriate answer for any given natural language input from your custom knowledge base of information.
Bot Framework Emulator
Emulator is a desktop application that allows bot developers to test and debug bots built using Composer. This tool allows for more advanced scenarios (like Authentication), which Composer's integrated Web Chat feature doesn't support at this time.
Create a Basic Bot with LUIS integration
Steps:
- Click on create new.
- Select Core Bot with Language and click on next.
- Give some name and select folder to save, be the app with azure web app and create.
It will run for some time to download template.
After that you will see this page with basic bot created.
We can see a basic bot with the following intent triggers:
- Greeting Trigger
- Cancel trigger
- Help Trigger
- Error occurred Trigger.
- Unknown Intent Trigger
and below dialogs:
- Cancel Di Talog
- Help Dialog
- Welcome Dialog
How to create an intent Trigger
Click on three dots in the base dialog and click on add new intent trigger like screenshot below:
Fill in the intent name and trigger phrases which are the utterances for the intent in below screenshot.
After adding it will look like this:
To add any logic or response click on plus icon like below:
After clicking send a response you will see a input field to fill in the text or attachments as a response:
you can use any property to get values as a text response:
we can also use in built functions to do some logic manipulation.
or you can add attachments or suggested actions.
In the attachment we can also create a list of available options - adaptive cards, hero card, etc.,
if you click on adaptive card it will generate a sample card in json which you can design and update using this site .
1. Greeting Trigger:
This is a Conversation Update activity trigger which happens on any conversation update. In which we are seeing a logic of getting member added property from 'turn.Activity.membersAdded' value and checking if the recipient is the member added then we can trigger Welcome dialog by this logic 'string(dialog.foreach.value.id) != string(turn.Activity.Recipient.id)'.
In Welcome Dialog:
We are checking whether the user is greeted from property: 'exists(user.greeted)' this is a custom property we are setting on first call to this welcome dialog, and it will be false so in false flow it will send a response to the user with intro message and set the 'user.greeted' property for this logic to work so that user is not greeted every time.
In Help intent trigger:
LUIS Configurations
Click on setup language understanding link in below screen shot
Select existing resources if the LUIS is already created in Azure.
else click on create and configure LUIS resources
After clicking on create resources then it will ask for login enter your azure login credentials and it will create the azure resources for you.
Also create Azure Bot resource in Azure then fill in the credentials of microsoft app id and password below:
After following these steps, you will get the values filled in here
on clicking the advanced settings radio button
After all these steps click on start bot
click on open in webchat to test the bot
Your bot is running successfully!
Thanks Happy Coding :)