Build chatbot with Azure
It's quite easy to build a chatbot with Azure, following the steps below to build your first chatbot;
Precondition:
- An Azure subscription
1. Create a Language service resource
Select the free tier for experimental purposes, it's enough to play with.
2. Create an AI Search resource, it is required for 'Custom question answering', you can also create the search resource when creating the 'Custom question answering'.
Select the free for experimental purposes, and at least the Basic tier for production.
3. After the AI Search is created, back to the Language service you created, in the 'Overview' tab, select 'Language Studio'
Select the 'Understand questions and conversation language' tab, and press 'Open Custom question answering' to create a new language project.
As your language resource was not yet connected to Azure Search, select 'Connect to Azure Search' to connect your language resource to the AI Search resource you just created.
If it's the first project you created in the language resource, you need to choose the language setting, you can choose to use a different language for each project in the language resource or use the same language for all the projects. I recommend you to choose the second option as the first option will cost more.
4. After the project is created, the next step is adding sources to it, these resources will be built into the knowledge base, so the bot can answer the questions from these imported sources. You can provide a source URL or upload a file directly, currently .docx, .excel, .pdf, and .txt are supported, there are different size limitations for each file type, so split the file into smaller ones if it exceeds the limitation.
Question answer pairs are automatically generated for the added source, you need to review each pair and revise it if necessary to build a reliable bot.
a. Revise the answer, this is the most part;
b. Add alternate questions, it makes your bot intelligent;
c. Add follow-up prompt for multi-turn scenario
d. Metadata is quite useful for question/answer filtering
Use the "Test" tool to verify if the bot works as expected, revise the question/answer pair if it's not.
5. Depoy the knowledge base and create a bot if you are satisfied with the test result, an 'App service plan' and 'User access management identity' are required when creating the bot, you can create these resources in advance(recommended) or create them together with the bot.
Now, you can play with the chatbot in Web Chat, hurrah, you get your own chatbot.
6. We can also integrate our chatbot into other communication applications, for example Slack.
To achieve this, you need to create a Slack app at https://api.slack.com/apps
Select the slack app you created, open the 'OAuth & Permissions' tab, and add 'https://slack.botframework.com' to 'Redirect URLs'
In the 'Event Subscriptions' tab, turn on 'Enable Events', and for 'Request URL', enter 'https://slack.botframework.com/api/Events/{bot-name}', where {bot-name}
is the display name for your Azure Bot resource, without the braces, then under 'Subscribe to bot events', select 'Add Bot User Event', and subscribe to the targeted events.
Select 'App Home', in the 'Show Tabs' section under the 'Messages Tab', and enable 'Allow users to send Slash commands and messages from the messages tab', this will enable users to message your bot.
Select the 'Basic Information' tab, under 'App Credentials', copy 'Client ID', 'Client Secret', and 'Signing Secret', they will be needed in the next step.
Back to the Azure bot, select Slack in the channels tab, and enter the required Slack credentials for the application you created in the Slack App, the 'OAuth & Permissions Redirect URL' and 'Event Subscription Request URL' values should match the values you entered in Slack App too.
Now, open your Slack, and you will find that the bot is shown in the Apps,
References:
https://learn.microsoft.com/en-us/azure/ai-services/language-service/question-answering/how-to/create-test-deploy
https://learn.microsoft.com/en-us/azure/ai-services/language-service/question-answering/tutorials/bot-service
https://learn.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-slack?view=azure-bot-service-4.0
https://learn.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-webchat?view=azure-bot-service-4.0
https://learn.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-wechat?view=azure-bot-service-4.0