23Aug
Create a simple Chatbot App using Botframework & Xamarin.Forms
We can integrate Chatbot API with Xamarin.Forms App using two methods,
- Embed Code with Web View or
- Native with DirectLine.
In this blog, I shall explain how to integrate Chatbot using embed code with WebView which is simple.
To achieve this, we need to have below 3 things set up
- An Azure account
- Create Bot Services on azure (For this demo we are using QnA Maker)
- Create a Xamarin App
Firstly, let us build an interactive QnA bot with the Cognitive Services of Microsoft. The purpose of this bot is to answer questions based on predefined set of answers.
Steps:
- Login to https://www.qnamaker.ai/ and click on Create a knowledge base.

- By clicking on Create a QnA service you will be redirected to Azure portal, please fill in all the required details and create a resource.

- After creating a resource come back to QnA Maker and Connect your QnA service to your KB by selecting all the appropriate details and give a name to your KB.

- Provide a QnA page URL or upload a QnA sheet. In this example I am using Azure Support FAQs URL https://azure.microsoft.com/en-in/support/faq/. After providing the URL click on Create your KB.

- Once your KB is created, click on My Knowledge Bases tab, it should list all the questions and answers from QnA URL provided or from the document you uploaded, click on Save and Train.

- You can also test your bot by clicking on Test on top right corner. You may now ask some questions from the QnA to ensure it answers correctly.

- Now under the Publish tab click on Publish to finalize your KB.
- Make sure to take a note of these 3 info, QnAKnowledgeBaseId, QnAEndPointHostName and QnAAuthKey.

- Now in the Azure Portal, search for Web App Bot. By creating Web App Bot, we can link the bot to the knowledge base and provide the interactive chatbot services on your website, Skype, Cortana, mobile app and many other channels.

- Click on Web App Bot, fill in all the required details and create a Question and Answer Bot.

- Before testing the bot, configuration of a QnA bot is mandatory. To test your bot in Web Chat, you must set the Application Settings, using your Hostname, KBId and Authkey what you had noted down earlier while publishing the QnA.

- Now you can test the bot by clicking on Test in Web Chat. Bot will respond for all the questions from KB.

Now your Chatbot is up and running 😊
Finally, all you need to do is, create a Xamarin.Forms App and Page with a WebView.

The source for the WebView and the secret keys can be obtained under the Channels tab

After setting source to the WebView, make sure to set your page as the main page in App.cs file, so that bot WebView is up and running once the app is started.
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new AzureFAQBotPage());
}
Once you build and deploy the app to your device, you are all set to chat with the bot 😊

Related
The Org Level Reports is one of the features in the DevOpSmartBoard which gives you an overview of a...
Read More >
Overview:In this blog I will demonstrate how to integrate the GitHub Advance Security Code scanning ...
Read More >
This feature is one with which we have simplification of user interface and faster work, but current...
Read More >
This is the final part of the Bugzilla to TFS Migrator blog series covering the actual steps of migr...
Read More >
What is SSRS reports?SSRS stands for SQL Server Reporting services a server based report generation ...
Read More >
What is CRM Today’s world is fast changing and full of challenges, which fundamenta...
Read More >
GitHub Apps are a really great way to extend GitHub and add custom integration. One of the trickier ...
Read More >
Howdy Folks!I was exploring Network Load Balancer in Azure Resource Manager and found out that you c...
Read More >
How to enable logging verbosity process parameter in build definition?Verbosity for a build will hel...
Read More >
Share