Home Technology peripherals AI Step-by-step instructions on how to create a chatbot using Azure Bot Services

Step-by-step instructions on how to create a chatbot using Azure Bot Services

Apr 11, 2023 pm 06:34 PM
robot develop

Translator | Li Rui​

Reviewer | Sun Shujuan​

Messengers, network services and other software are inseparable from robots (bots). In software development and applications, a bot is an application designed to automatically perform (or perform according to a preset script) actions created in response to user requests. In this article, Daniil Mikhov, developer at NIX United, presents an example of creating a chatbot using Microsoft Azure Bot Services. This article will be helpful to developers who want to develop chatbots using this service. Why use Azure Bot Services? ​

The advantage of developing chatbots on Azure Bot Services is Microsoft’s high level of support for its products. The company's experts actively communicate with the technical community and quickly identify and fix vulnerabilities in the service. Additionally, Microsoft provides the ability to create custom JSON files to work with some of Messenger’s APIs, giving developers a lot of possibilities when creating chatbots.

It’s also important to remember the other benefits of Azure Bot Services:

Azure Bot Services allows Developers use open source SDK tools (software development kits) to create, test and deploy chatbots.

  • #Integration with cognitive services refers to services that use machine learning tools at work to solve typical tasks. Cognitive services ensure a better interaction process between the chatbot and the user.
  • Multi-platform refers to the ability to connect a chatbot to multiple channels without changing the original code.
  • Plenty of open source examples to facilitate the development process and get started quickly (there are many ready-made code examples on GitHub).
  • Developers can extend the chatbot infrastructure on the Azure platform by adding new features. For example, you can add more channels and use each channel for testing. The Cosmos DB service can be used to store conversation state and user-entered information. To train your chatbot, you can add language understanding (LUIS). It uses machine learning algorithms to better communicate with users. However, LUIS is not free, and not every client wants to allocate additional funds.

Analysis of Chatbot in Azure Bot Services​

The functional structure of a chatbot created on Azure can be expressed as:

You can see a list of possible channels connected to the chatbot on the right. This list will be continuously updated with new platforms. At the bottom of it are Microsoft Cognitive Services available on the Azure platform. These services allow communication with chatbots through voice requests, facial expressions, gestures, and more. Step-by-step instructions on how to create a chatbot using Azure Bot Services

Bot Builder SDK is used to develop chatbots on Azure. The product is in the public domain and its main advantage is ongoing support from developers. In a separate fork on GitHub, you can get the latest information about the service, or ask its developers questions.

Create Chatbot​

Before writing the code, analyze the nuances that you should consider before creating a chatbot on Azure Bot Service :

  • Updates that break functionality. Microsoft Corporation is constantly updating its products. New updates often break parts of code that worked before. So be sure to understand the patch list for new Bot Builder SDK versions, and other manuals used to develop chatbots may become irrelevant.
  • Not an obvious solution. When using the Bot Builder SDK, you should always be open to experimentation and willing to do things differently than you are used to.
  • Versatility. The same chatbot can be uploaded to different channels (Telegram, Skype, Slack, etc.) without changing the source code. You should keep in mind when developing chatbots that each platform has nuances that require developers to take a different approach when creating the working logic of the application.

(1) Can chatbots correctly understand people’s questions?

Communication with the chatbot takes place through the user interface. The user interface allows developers to communicate with the chatbot in a language it understands. For this purpose, Microsoft Azure uses a dialog system that follows a specific hierarchy:

Step-by-step instructions on how to create a chatbot using Azure Bot Services

Here you can See three basic ways to establish a conversation with a chatbot:

  • Prompts – Chatbots interact with users through prompts and answers. For example, chatbot information is given in the form of digital prompts. Prompt checks whether the user answered the prompt correctly. If successful, the conversation with the chatbot will continue. If an incorrect answer is received from the user, he will be prompted to enter valid data.
  • Waterfall – Waterfall is a method of gathering information from users through a series of consecutive tasks/questions. Each step of the waterfall dialog is implemented as an asynchronous function. At each stage, the chatbot asks the user to enter data, waits for a response, and then passes the results to the next step. The result of the first function is passed as a parameter to the next function, and so on until the entire problem loop has been passed.
  • # Components - Components are a way to break down a large dialog box into smaller, manageable parts. Components allow developers to create a reusable dialog box and use it later in a variety of independent scenarios. For example, you can use this to create a dialog box that will ask the user for a street name/address/zip code in sequence.

On the bottom line, you can see the allowed methods for creating custom requests for the chatbot:

  • Text query (text)
  • ##Number query (quantity)
  • Date/Time Request (Date Time)
  • Confirm Request (Confirm)
  • Select request (select)
  • ##Attachment request (attachment)
In essence, the query is a staged dialog: in the first stage, the chatbot requests input data

In the second phase, it returns a valid value to the user or restarts the data query loop if an invalid value is received.

(2) Controller and template

Look below## Code from the "Remind me later" chatbot example created by

#Daniil Mikhov, whose main task is to remind him of any action he needs to take in the future.

To create the chatbot, Mikhov used the Empty Template provided by Visual Studio, which includes several types of controllers: BotController and NotifyController.

BotController receives messages for the chatbot and passes them to the chatbot framework. Chatbot also includes several deployment templates for easier deployment of applications to the Azure platform.

Step-by-step instructions on how to create a chatbot using Azure Bot Services

The Notify Controller determines when to send a message to the user. This issue will be discussed in more detail later.

(3) Start the function and populate the ToDoDialog tab

##Go to Startup.cs tab to view its contents. Here you can see the registered error handler AdapterWithErrorHandler. If an error occurs in a program, the application's reaction to the error is necessary. Note registering ConversationState - use this to let the chatbot know which user it is communicating with and at what stage of the conversation.

Step-by-step instructions on how to create a chatbot using Azure Bot Services

Let’s take a look at the contents of the ToDoDialog.cs tab. Mikhov declares waterfallSteps, which is a set of steps in the waterfall dialog box, which has been mentioned above. In waterfallSteps, specify which asynchronous functions are used in each step to build the conversation between the user and the chatbot.

Step-by-step instructions on how to create a chatbot using Azure Bot Services

Below you can see what type of input prompts the chatbot will use. The content here is pretty standard: the chatbot will ask people some questions about the event and then provide scheduling reminders.

Step-by-step instructions on how to create a chatbot using Azure Bot Services

Now run the chatbot and test its operation using the Bot Framework Emulator interface.

# (4) First launch and test in the chatbot framework simulator

When running this application, a link to the URL where the chatbot will wait for user messages will appear.

Step-by-step instructions on how to create a chatbot using Azure Bot Services

Before starting the test, specify this link in the chatbot framework simulator:

Step-by-step instructions on how to create a chatbot using Azure Bot Services

In the first communication step, the chatbot asks the user to enter the name of the event that needs to be reminded. To do this, call the following code :

Step-by-step instructions on how to create a chatbot using Azure Bot Services

Now, when When the chatbot is called, it will return the following text: Please enter a description of the event. After declaring the event (such as buying milk) that you want to be reminded of, call the code in the second step. Here, the chatbot will provide one of three reminder time options:

Step-by-step instructions on how to create a chatbot using Azure Bot Services

Pay attention to the use of stepContext. It saves all information about the dialog box, recording intermediate values. To implement a list of possible reminder times, ChoicePrompt is used. This method will provide the user with three options and a possible reminder time (2 minutes, 5 minutes, or the same time the next day) . There could have been more choices, but only three were chosen.

Using selection to represent each new selection time, you can get:

Step-by-step instructions on how to create a chatbot using Azure Bot Services

In the chatbot framework simulator, this code will be rendered like this:

Step-by-step instructions on how to create a chatbot using Azure Bot Services

You can use Parse to parse the results. As a reminder, parsing is an automated process of collecting data and structuring it. The chatbot will then ask the user if they are sure about the selected reminder time, using ConfirmPrompt to confirm the agreement:

Step-by-step instructions on how to create a chatbot using Azure Bot Services

From the visual Look, this method looks like this:

Step-by-step instructions on how to create a chatbot using Azure Bot Services

The last step is to take out the previously filled in information from stepContext and Generates a SavedNotificationModel to which a conversationReference must be added. Without it, the chatbot cannot resume the conversation with the user or determine which user specifically addressed the issue.

Step-by-step instructions on how to create a chatbot using Azure Bot Services

MikhovUsing the dictionary method as a temporary repository for these events, thanks to its adoption, The chatbot assigns its unique instanceId to each specific dialog:

Step-by-step instructions on how to create a chatbot using Azure Bot Services

This will end up with the chatbot dialogue. You can display text to the user indicating the end of the dialog box and create a corresponding reminder request: "Thank you. The notification was saved successfully".

Step-by-step instructions on how to create a chatbot using Azure Bot Services

(5) How does a chatbot travel through time​

For To locate the chatbot in time, Mikhov created the notifiedcontroller method NotifyTimeCheck(). This approach allows the application to be systematically polled and if a certain event is about to occur, the chatbot will retrieve the event from the dictionary and send a notification to the user.

Step-by-step instructions on how to create a chatbot using Azure Bot Services

To get notified, the BotAdapter's ContinueConversationAsync() method is called, passing the ConversationReference to it. The first parameter of ContinueConversationAsync() must always be the appId (application ID) of the chatbot service, otherwise, it will not work.

In addition, the chatbot also needs to be reminded that when a certain time arrives, the event must be reminded to the specific user. Developers can use Azure Function (BotTimerFunction), which will be triggered by a time trigger (TimerTrigger).

Step-by-step instructions on how to create a chatbot using Azure Bot Services

Every minute, the function will send a request to this endpoint and start checking for the specified events. If it reaches the correct time frame, the chatbot will notify the user that the scheduled event is about to occur.

Today, WhatsApp, Facebook Messenger, Telegram and other communication tools are not only communication platforms, but also business platforms. Chatbots help businesses effectively sell and promote goods and services online. Automating daily processes, providing necessary product information to customers in a timely manner, receiving and processing requests – all these features of a properly configured chatbot will help convert users into customers. Therefore, as a developer, you should remember how popular this tool is now and how cool it is to be able to create such an application and become a popular expert as a result.

Original title: How to Create a Chatbot Using Azure Bot Service: Step-by-Step InstructionAuthor: Daniil Mikhov


The above is the detailed content of Step-by-step instructions on how to create a chatbot using Azure Bot Services. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Four recommended AI-assisted programming tools Four recommended AI-assisted programming tools Apr 22, 2024 pm 05:34 PM

This AI-assisted programming tool has unearthed a large number of useful AI-assisted programming tools in this stage of rapid AI development. AI-assisted programming tools can improve development efficiency, improve code quality, and reduce bug rates. They are important assistants in the modern software development process. Today Dayao will share with you 4 AI-assisted programming tools (and all support C# language). I hope it will be helpful to everyone. https://github.com/YSGStudyHards/DotNetGuide1.GitHubCopilotGitHubCopilot is an AI coding assistant that helps you write code faster and with less effort, so you can focus more on problem solving and collaboration. Git

How can AI make robots more autonomous and adaptable? How can AI make robots more autonomous and adaptable? Jun 03, 2024 pm 07:18 PM

In the field of industrial automation technology, there are two recent hot spots that are difficult to ignore: artificial intelligence (AI) and Nvidia. Don’t change the meaning of the original content, fine-tune the content, rewrite the content, don’t continue: “Not only that, the two are closely related, because Nvidia is expanding beyond just its original graphics processing units (GPUs). The technology extends to the field of digital twins and is closely connected to emerging AI technologies. "Recently, NVIDIA has reached cooperation with many industrial companies, including leading industrial automation companies such as Aveva, Rockwell Automation, Siemens and Schneider Electric, as well as Teradyne Robotics and its MiR and Universal Robots companies. Recently,Nvidiahascoll

After 2 months, the humanoid robot Walker S can fold clothes After 2 months, the humanoid robot Walker S can fold clothes Apr 03, 2024 am 08:01 AM

Editor of Machine Power Report: Wu Xin The domestic version of the humanoid robot + large model team completed the operation task of complex flexible materials such as folding clothes for the first time. With the unveiling of Figure01, which integrates OpenAI's multi-modal large model, the related progress of domestic peers has been attracting attention. Just yesterday, UBTECH, China's "number one humanoid robot stock", released the first demo of the humanoid robot WalkerS that is deeply integrated with Baidu Wenxin's large model, showing some interesting new features. Now, WalkerS, blessed by Baidu Wenxin’s large model capabilities, looks like this. Like Figure01, WalkerS does not move around, but stands behind a desk to complete a series of tasks. It can follow human commands and fold clothes

The first robot to autonomously complete human tasks appears, with five fingers that are flexible and fast, and large models support virtual space training The first robot to autonomously complete human tasks appears, with five fingers that are flexible and fast, and large models support virtual space training Mar 11, 2024 pm 12:10 PM

This week, FigureAI, a robotics company invested by OpenAI, Microsoft, Bezos, and Nvidia, announced that it has received nearly $700 million in financing and plans to develop a humanoid robot that can walk independently within the next year. And Tesla’s Optimus Prime has repeatedly received good news. No one doubts that this year will be the year when humanoid robots explode. SanctuaryAI, a Canadian-based robotics company, recently released a new humanoid robot, Phoenix. Officials claim that it can complete many tasks autonomously at the same speed as humans. Pheonix, the world's first robot that can autonomously complete tasks at human speeds, can gently grab, move and elegantly place each object to its left and right sides. It can autonomously identify objects

Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Apr 07, 2024 am 09:10 AM

On March 3, 2022, less than a month after the birth of the world's first AI programmer Devin, the NLP team of Princeton University developed an open source AI programmer SWE-agent. It leverages the GPT-4 model to automatically resolve issues in GitHub repositories. SWE-agent's performance on the SWE-bench test set is similar to Devin, taking an average of 93 seconds and solving 12.29% of the problems. By interacting with a dedicated terminal, SWE-agent can open and search file contents, use automatic syntax checking, edit specific lines, and write and execute tests. (Note: The above content is a slight adjustment of the original content, but the key information in the original text is retained and does not exceed the specified word limit.) SWE-A

Learn how to develop mobile applications using Go language Learn how to develop mobile applications using Go language Mar 28, 2024 pm 10:00 PM

Go language development mobile application tutorial As the mobile application market continues to boom, more and more developers are beginning to explore how to use Go language to develop mobile applications. As a simple and efficient programming language, Go language has also shown strong potential in mobile application development. This article will introduce in detail how to use Go language to develop mobile applications, and attach specific code examples to help readers get started quickly and start developing their own mobile applications. 1. Preparation Before starting, we need to prepare the development environment and tools. head

Ten humanoid robots shaping the future Ten humanoid robots shaping the future Mar 22, 2024 pm 08:51 PM

The following 10 humanoid robots are shaping our future: 1. ASIMO: Developed by Honda, ASIMO is one of the most well-known humanoid robots. Standing 4 feet tall and weighing 119 pounds, ASIMO is equipped with advanced sensors and artificial intelligence capabilities that allow it to navigate complex environments and interact with humans. ASIMO's versatility makes it suitable for a variety of tasks, from assisting people with disabilities to delivering presentations at events. 2. Pepper: Created by Softbank Robotics, Pepper aims to be a social companion for humans. With its expressive face and ability to recognize emotions, Pepper can participate in conversations, help in retail settings, and even provide educational support. Pepper's

Cloud Whale Xiaoyao 001 sweeping and mopping robot has a 'brain'! | Experience Cloud Whale Xiaoyao 001 sweeping and mopping robot has a 'brain'! | Experience Apr 26, 2024 pm 04:22 PM

Sweeping and mopping robots are one of the most popular smart home appliances among consumers in recent years. The convenience of operation it brings, or even the need for no operation, allows lazy people to free their hands, allowing consumers to "liberate" from daily housework and spend more time on the things they like. Improved quality of life in disguised form. Riding on this craze, almost all home appliance brands on the market are making their own sweeping and mopping robots, making the entire sweeping and mopping robot market very lively. However, the rapid expansion of the market will inevitably bring about a hidden danger: many manufacturers will use the tactics of sea of ​​machines to quickly occupy more market share, resulting in many new products without any upgrade points. It is also said that they are "matryoshka" models. Not an exaggeration. However, not all sweeping and mopping robots are

See all articles