Fine-Tuning Your Chatbot
- By Joe Mayo
In this sample chapter from Programming the Microsoft Bot Framework: A Multiplatform Approach to Building Chatbots, readers take a deep dive into Bot Emulator features and learn how to perform testing from user to chatbot.
Most software development projects have common tasks for design, coding, and deployment. There are also a common set of tasks surrounding maintenance, quality, security, and user experience that are often not documented, but remain vital considerations for a healthy project. These are continuous tasks, so it’s important to learn about ways to approach them early with the Bot Framework and carry the skillset through the rest of this book and beyond. We are pulling these additional tasks together under a general category of fine-tuning.
You’ve used the Bot Emulator in previous chapters to interact with chatbots, but that was a minimal introduction. This chapter does a deep dive of Bot Emulator features and shows how to perform testing from user to chatbot. This chapter is also a continuation of Chapter 3, “Building Conversations: The Essentials,” where there’s a detailed explanation of Activities, communications between a chatbot and the Bot Connector, and how the Bot Emulator facilitates testing Activities.
Reviewing Bot Emulator Details
In addition to having conversations, the Bot Emulator offers several other features for testing and verifying the operation of a chatbot. At first glance, you can see that the Bot Emulator has sections for Connection Details, Conversation Display, Message Input, Details, and Log. Figure 4-1 shows each section of the Bot Emulator.
FIGURE 4-1 Sections of the Bot Emulator.
Clicking the address bar at the top left causes the Bot Emulator to display the Connection Details area. Chapter 2 explained how to obtain Microsoft App ID and Microsoft App Password from the Registration page on the Microsoft Bot Framework page. The Locale field, containing en-US lets you populate a custom locale for testing localization. In the code, you can read that value via the Activity.Locale field. Clicking Connect hides the Connection Details window and enables the Message Input box.
As shown several times in previous chapters, type any text into the Message Input field and either press Enter or click the arrow button on the right to send a message to the chatbot. Clicking the button on the left of the Message Input, with the picture icon, opens the File dialog so you can attach a file and sent it to the chatbot, which is covered in more detail in Chapter 10.
Sending a message to the chatbot also shows what you typed on the right side of the Conversation Display. Messages from the chatbot show on the left side of the Conversation Display. Notice the dark highlight on the final message in the Figure 4-1 Message Display, ending with You win. This displays the message sent to the chatbot to appear in the Details section.
The Details section shows messages between Bot Emulator and chatbot. Details shows JSON formatted messages. Read the message in Details any time you want to know the exact details of the data transferred between Bot Emulator and chatbot.
Use the Log section to see the type of messages between Bot Emulator and chatbot. This shows time, HTTP status, and a quick description of what transferred. Figure 4-1 shows POST and GET messages for the current conversation. The timings give you some idea of when a message transferred and how long it took between messages and the arrows show the direction of the messages, where pointing right is a message to the chatbot, and pointing left is a message to the Bot Emulator. There is a hyperlink on each status that you click to make the message display in the Details section.
The Bot Emulator also lets you test Activities, which you’ll learn about in the next section.