Let's build a Free Web Chat Bot - Part 2/2
Ivan Vydrin
Software Engineer | .NET & Azure Professional | AI/ML Enthusiast | Crafting Scalable and Resilient Solutions
In today's fast-moving digital world, smart and intuitive conversations give businesses a real edge. Azure AI Services provide a powerful platform to build, deploy, and scale AI-driven applications. A standout example? Combining Azure Cognitive Services for Language with Azure Bot Service to create intelligent, natural-language chatbots.
Want to take it further? This article walks you through integrating a knowledge base into your Azure AI Bot and building a fully functional web app. Read now and level up!
What is Azure AI Bot Service?
Azure AI Bot Service is a comprehensive cloud platform that simplifies building, deploying, and managing intelligent chatbots. It integrates seamlessly with Azure Cognitive Services to empower bots with natural language understanding, making it easy to create engaging and personalized conversational experiences across multiple channels.
Step-by-step guidance
In our previous article, we reached step 7?? by setting up the infrastructure and deploying our Knowledge Base.
Now, we'll integrate it with the Azure AI Bot Service and connect it to our .NET application. Let's dive in!
8?? Click the "Create a bot" button and proceed with its creation.
Choose the "Free" pricing tier and click the "Next" button:
Next, create a new App Service plan for your bot. By default, it uses the S1 Standard tier, but you can change the pricing later - or set up the plan in advance with your preferred pricing tier.
Important: The Language Resource Key is essential for integrating your Language resource with your Bot's App Service (Web App).
(Remember, you created the Language resource in the previous article). You can find the endpoint key in the Language > Keys and Endpoint section.
Then click "Review + Create" and wait for deployment to be completed.
9?? Once the deployment is complete, navigate to your new Bot resource and verify its functionality using the Test in Web Chat feature.
Next, check the Channels section to explore your integration options.
领英推荐
We'll connect via Direct Line - so simply create it with default configurations by clicking New Site tab (if it is not created yet), head over there and note the Secret Key, which you'll need for your .NET web app in the next step.
?? In this final step, we'll create the web app to integrate the Bot.
Note: in the example below, I've used the GitHub Copilot Workspace to implement the .NET Web App. It was deployed for Demo purposes and is not ready for usage in Production! For additional working examples and more advanced Bot implementations, check out this link.
The two main settings required for Web App:
Copy and paste them to the appsettings.json:
Important: do not store the sensitive information such as Direct Line secret in such a way! Use more secured approaches such as Azure Key Vault instead.
1) Direct Line secret is used to establish the connection to Bot in BotService.cs:
public BotService(IOptions<BotConfig> config, ILogger<BotService> logger)
{
...
_directLineClient = new DirectLineClient(_config.DirectLineSecret);
}
2) Bot ID is used to understand what messages are being sent to the Chat by Bot:
Task<IEnumerable<BotResponseDto>> ReceiveMessagesAsync(string conversationId)
{
...
return activitySet.Activities
.Where(activity => activity.From.Id == _config.BotId && activity.Type == ActivityTypes.Message)
.Select(MapActivityToBotResponse);
...
}
After setting the configurations, the Web App is ready for usage:
The link to GitHub repository:
Your Free Web Chat Bot is ready! With this guide, you can set up the basic infrastructure and implement your web app in under an hour. Your Knowledge Base is securely stored in the cloud, ensuring your data is protected.
Tuning the Bot doesn't require specialized expertise - just a solid understanding of your business domain and desired outcomes. Plus, you can adjust it on the fly as your needs evolve. The Knowledge Base also offers valuable metrics, highlighting frequently asked questions and identifying areas where improvements are needed.
That's it! Feel free to share your results in the comments! Any suggestions, contributions and feedback are highly appreciated. Subscribe to this newsletter to not miss more useful information.