Xamarin Forms ChatBot using the Microsoft Bot Framework
Xamarin Forms ChatBot using the Microsoft Bot Framework
Introduction:
The Bots Framework that run inside skype ,web chat , Facebook ,Message ,etc. Users can interact with bots by sending them messages, commands and inline requests. You control your bots using HTTPS requests to our bot API.In this article, how you can integrate a bot right into your Xamarin.Forms application via the Microsoft Bot Framework Web bots.
Create new bot Application:
You can read my previous article for Getting Started with Bots Using Visual Studio 2019 from herePublish Bot Application to Azure:
You can read my previous articles for publish bot application to azure from hereGenerate Web Chat Code:
After publish you bots into azure, you can generate web Chat html code from bots portal as per belowStep 1
Sign in to the Bot framework Portal - https://dev.botframework.com/Step 2
Click My BotsStep 3
Select your bot that you want to generate codeStep 4:
Click on Get bot embed Codes > Click on Web Chat icon > Click on (Click here to open Web Chat configuration page)Step 5:
It will navigate to new web page for configuration and click on + Add New Site > Provide site or application name > Click on DoneStep 6:
You can copy your secret keys and embed code for integrate to xamarin forms applicationCreate new Xamarin .Forms Application :
Go to Run (Windows key +R) > type Devenv.exe or select from Windows Application list and select New project from File menu > New Project (ctrl +Shift+N) or click More project template from VS Start screen.New Project >select Cross -Platform from Template > Cross platform App(Xamarin.Forms or native). It will show the screen, as shown below.
You can find above screen only on VS 2017. Select Blank apps > select Xamarin.Forms > Select PCL and click on Ok .it will generate all the mobile platform project with PC
Open your MainPage.xaml file add webview control with following code for web chat enable
<StackLayout WidthRequest="300" HeightRequest="500" >
<Image Source="profile.png" WidthRequest="200" HeightRequest="200"></Image>
<Label Text="Live Chat with Suthahar via C Sharp corner" FontSize="20" ></Label>
<WebView x:Name="webview" Source="https://webchat.botframework.com/embed/DevEnvExeBot?s=8XGcUROXkAA.cwA.pZo.8pJ-6oQ3sJRpxq0tqIo9uLPji4oxBQuz2pW5qWobw2c"
WidthRequest="300" HeightRequest=" 300"></WebView>
</StackLayout>
Now you can run the application in windows ,Android and iOS
0 Comments