How to create a chatbot with Azure in 5 minutes

How to create a chatbot with Azure in 5 minutes

How to create a chatbot with Azure in 5 minutes

SQLShack

SQL Server training Español

How to create a chatbot with Azure in 5 minutes

June 19, 2017 by Minette Steynberg

Introduction

As we enter an era of artificial intelligence and serverless computing, the tools to help us create perceived intelligent programs have become so advanced and intuitive that the effort in building a fully functional Q and A chat bot has become almost negligible. In this article, I will show you how to do just that.

About Q and A bots

The thing about Q & A bots are, that they are only as good as the questions and answers you provide them. Ultimately, they are not very clever, they serve a specific purpose which is to provide programmed responses to predefined questions. It displays some intelligence in the sense that it can match a free text question asked by a person to the questions it has in its knowledge base even if it’s not asked in exactly the same way. Of course once you have a Q & A bot, nothing stops you from extending your bot to do other fabulous things such as identifying pictures with the Computer Vision API or determining Emotion with the Emotion API But for the purpose of this article we will build a plain and simple Q and A bot. Let’s get started.

Step 1 Building the knowledge base

To build the knowledge base we will make use of a very handy website called QnA Maker. Click on Create new service In the create new service window add: The Service name The URL of the FAQ page you would like to use You don’t necessarily have to use an FAQ page. You can upload a Word Document, text file or a .pdf with question and answer pairs. Strangely it does not accept an Excel spreadsheet. Upload a file with questions or answers. You don’t have to choose between a website FAQ or a file. You can do either or both or multiple websites or multiple files or you don’t have to do either and just type questions and answers from scratch. It’s entirely up to you. Click Create The QnA Maker will proceed to generate the knowledge base from the FAQs provided. In this case it extracted 18 Q and A pairs from the website. You can click here to add another Q and A pair. This will be added in the Editorial section. This displays the source of the Q and A. In this particular case, we only have 2 sources: The original source: Editorial and the FAQ website. Save and retrain. To see changes you made to the knowledge base you should save and retrain it for the changes to take effect. Before the knowledge base will become available for use by a real bot it should be published which I will discuss a little bit later. Go to the Test tab to test the knowledge base. Let’s to that now: Here is where I would type my question. As you can see, the first question I typed was “How good is your support?”, the actual question on the FAQ was, “Is your support any good?” so the bot was at least clever enough to understand that it is almost the same question. Notice that all the links which were in the FAQ page remains active and clickable as before. If the bot did not pick the most appropriate answer, it lists other answers here which it might think is appropriate. Or you can select none of the above to leave it as is. If you changed anything here, you must click on (4) Save and Retrain before asking another question or it won’t be applied. Here you can provide alternative phrasings. So, if you want someone to be able to ask: “Can you do a demonstration?” as well as “Do you do demos?”, you can add this here and similarly to above click on (4) Save and Retrain before doing any other action. Save and retrain Once you are happy with the knowledge base. Click on Publish. A summary screen will appear. Number of Q and A in the current knowledge base. The number of Q and A just added. In this case, everything was just added, since its new. The number of Q and A deleted if there are any. Click publish again when you are satisfied that the summary is reflecting your intensions correctly. This will publish the Q and A service and create an Endpoint.

Step 2 Creating the bot

To create the bot, we need to login to Azure. In Azure Market place search for Bot Service and click on it. This will take you to the Bot pre-creation screen which provides some useful links to documentation and pricing details. Click on Create To create the bot: Add a name for the bot. This needs to be a unique name and it will indicate with the green check mark on the right, if its accepted or not. Select the subscription you want to use. Create a new resource group or use an existing one. Select the region where you’d like your bot to reside. I usually pin my stuff to the dashboard just so that I can find it again easily. Click create. Once the bot is created you will be required to create a Microsoft App ID and Password. This is done in the Application Registration Portal. You will be automatically directed to the portal when you click on the “Create Microsoft App ID and password” button. Click on the Create Microsoft App ID and password button. This will require you to login using a live account. Once you completed the login. It will automatically generate an App ID. Click on the “Generate an app password to continue”. This will show a popup with your new password. Copy this password and also save it somewhere with the App ID in case you need it again in the future. Click ok. And on the next screen click: This should take you back to Azure where you left off your bot configuration. Paste the password which you just copied into the password field. Choose your preferred language. I prefer C#, but you can use Node.JS as well. Here you have to choose a template. In this case we will select the Question and Answer Template because it happens to be exactly what we want to do. Agree to terms and conditions. Click on “Create bot” A popup will appear to connect the bot to the QnA Maker. Because I signed in in both instances with my live account, and I published my knowledge base my knowledge base should be available to select from the dropdown. Select the knowledge base previously created. Click ok. Once the bot is created, your screen will look something like this: (I will discuss each briefly but it’s really outside the scope of this article.) This is the current tab, where you can modify the source code. The channels tab allows you to connect your bot to multiple channels, by default it can connect to Skype and Web Chat. The analytics screen gives you basic statistics as to how many users chatted through which channels. The settings tab lets you change the configuration of the bot. Including the name, the icon, the knowledge base, cognitive services, continuous integration etc. The test tab allows you to test the bot. This is different from testing the knowledge base, because it actually tests the knowledge base as it reacts when being called through the bot. So, any changes made to the bot code will also be visible here, whereas those changes will not be visible in the test of the QnA Maker. To finish this off I am now going to add this bot to my skype as a contact. On the channels tab, click on the Skype channel. This will appear: Click on add to contacts. It will be added to your skype contacts, and you can then chat with your bot.

Conclusion

I hope that you were able to see just how easy it is to create a Q and A bot and that this will inspire you to play around with bots and expand on this simple one by adding cognitive services and machine learning. Author Recent Posts Minette SteynbergMinette Steynberg has over 15 years’ experience in working with data in different IT roles including SQL developer and SQL Server DBA to name but a few. Minette enjoys being an active member of the SQL Server community by writing articles and the occasional talk at SQL user groups.

Minette currently works as a Data Platform Solution Architect at Microsoft South Africa.

View all posts by Minette Steynberg Latest posts by Minette Steynberg (see all) The end is nigh! (For SQL Server 2008 and SQL Server 2008 R2) - April 4, 2018 8 things to know about Azure Cosmos DB (formerly DocumentDB) - September 4, 2017 Introduction to Azure SQL Data Warehouse - August 29, 2017

Related posts

Azure Cosmos DB from zero to 10 minutes Overview of the CREATE DATABASE statement in Azure SQL Server Create Azure Data Warehouse reports using Azure Power BI How to use PowerShell to create a SQL Virtual Machine in Azure How to create an Azure SQL Database using the Cloud Shell 5,482 Views

Follow us

Popular

SQL Convert Date functions and formats SQL Variables: Basics and usage SQL PARTITION BY Clause overview Different ways to SQL delete duplicate rows from a SQL Table How to UPDATE from a SELECT statement in SQL Server SQL Server functions for converting a String to a Date SELECT INTO TEMP TABLE statement in SQL Server SQL WHILE loop with simple examples How to backup and restore MySQL databases using the mysqldump command CASE statement in SQL Overview of SQL RANK functions Understanding the SQL MERGE statement INSERT INTO SELECT statement overview and examples SQL multiple joins for beginners with examples Understanding the SQL Decimal data type DELETE CASCADE and UPDATE CASCADE in SQL Server foreign key SQL Not Equal Operator introduction and examples SQL CROSS JOIN with examples The Table Variable in SQL Server SQL Server table hints – WITH (NOLOCK) best practices

Trending

SQL Server Transaction Log Backup, Truncate and Shrink Operations Six different methods to copy tables between databases in SQL Server How to implement error handling in SQL Server Working with the SQL Server command line (sqlcmd) Methods to avoid the SQL divide by zero error Query optimization techniques in SQL Server: tips and tricks How to create and configure a linked server in SQL Server Management Studio SQL replace: How to replace ASCII special characters in SQL Server How to identify slow running queries in SQL Server SQL varchar data type deep dive How to implement array-like functionality in SQL Server All about locking in SQL Server SQL Server stored procedures for beginners Database table partitioning in SQL Server How to drop temp tables in SQL Server How to determine free space and file size for SQL Server databases Using PowerShell to split a string into an array KILL SPID command in SQL Server How to install SQL Server Express edition SQL Union overview, usage and examples

Solutions

Read a SQL Server transaction logSQL Server database auditing techniquesHow to recover SQL Server data from accidental UPDATE and DELETE operationsHow to quickly search for SQL database data and objectsSynchronize SQL Server databases in different remote sourcesRecover SQL data from a dropped table without backupsHow to restore specific table(s) from a SQL Server database backupRecover deleted SQL data from transaction logsHow to recover SQL Server data from accidental updates without backupsAutomatically compare and synchronize SQL Server dataOpen LDF file and view LDF file contentQuickly convert SQL code to language-specific client codeHow to recover a single table from a SQL Server database backupRecover data lost due to a TRUNCATE operation without backupsHow to recover SQL Server data from accidental DELETE, TRUNCATE and DROP operationsReverting your SQL Server database back to a specific point in timeHow to create SSIS package documentationMigrate a SQL Server database to a newer version of SQL ServerHow to restore a SQL Server database backup to an older version of SQL Server

Categories and tips

►Auditing and compliance (50) Auditing (40) Data classification (1) Data masking (9) Azure (295) Azure Data Studio (46) Backup and restore (108) ►Business Intelligence (482) Analysis Services (SSAS) (47) Biml (10) Data Mining (14) Data Quality Services (4) Data Tools (SSDT) (13) Data Warehouse (16) Excel (20) General (39) Integration Services (SSIS) (125) Master Data Services (6) OLAP cube (15) PowerBI (95) Reporting Services (SSRS) (67) Data science (21) ►Database design (233) Clustering (16) Common Table Expressions (CTE) (11) Concurrency (1) Constraints (8) Data types (11) FILESTREAM (22) General database design (104) Partitioning (13) Relationships and dependencies (12) Temporal tables (12) Views (16) ►Database development (418) Comparison (4) Continuous delivery (CD) (5) Continuous integration (CI) (11) Development (146) Functions (106) Hyper-V (1) Search (10) Source Control (15) SQL unit testing (23) Stored procedures (34) String Concatenation (2) Synonyms (1) Team Explorer (2) Testing (35) Visual Studio (14) DBAtools (35) DevOps (23) DevSecOps (2) Documentation (22) ETL (76) ►Features (213) Adaptive query processing (11) Bulk insert (16) Database mail (10) DBCC (7) Experimentation Assistant (DEA) (3) High Availability (36) Query store (10) Replication (40) Transaction log (59) Transparent Data Encryption (TDE) (21) Importing, exporting (51) Installation, setup and configuration (121) Jobs (42) ►Languages and coding (686) Cursors (9) DDL (9) DML (6) JSON (17) PowerShell (77) Python (37) R (16) SQL commands (196) SQLCMD (7) String functions (21) T-SQL (275) XML (15) Lists (12) Machine learning (37) Maintenance (99) Migration (50) Miscellaneous (1) ►Performance tuning (869) Alerting (8) Always On Availability Groups (82) Buffer Pool Extension (BPE) (9) Columnstore index (9) Deadlocks (16) Execution plans (125) In-Memory OLTP (22) Indexes (79) Latches (5) Locking (10) Monitoring (100) Performance (196) Performance counters (28) Performance Testing (9) Query analysis (121) Reports (20) SSAS monitoring (3) SSIS monitoring (10) SSRS monitoring (4) Wait types (11) ►Professional development (68) Professional development (27) Project management (9) SQL interview questions (32) Recovery (33) Security (84) Server management (24) SQL Azure (271) SQL Server Management Studio (SSMS) (90) SQL Server on Linux (21) ►SQL Server versions (177) SQL Server 2012 (6) SQL Server 2016 (63) SQL Server 2017 (49) SQL Server 2019 (57) SQL Server 2022 (2) ►Technologies (334) AWS (45) AWS RDS (56) Azure Cosmos DB (28) Containers (12) Docker (9) Graph database (13) Kerberos (2) Kubernetes (1) Linux (44) LocalDB (2) MySQL (49) Oracle (10) PolyBase (10) PostgreSQL (36) SharePoint (4) Ubuntu (13) Uncategorized (4) Utilities (21) Helpers and best practices BI performance counters SQL code smells rules SQL Server wait types © 2022 Quest Software Inc. ALL RIGHTS RESERVED. GDPR Terms of Use Privacy
Share:
0 comments

Comments (0)

Leave a Comment

Minimum 10 characters required

* All fields are required. Comments are moderated before appearing.

No comments yet. Be the first to comment!