Home
%3CLINGO-SUB%20id%3D%22lingo-sub-393113%22%20slang%3D%22en-US%22%3EBot%20components%3A%20roles%2C%20diagrams%2C%20overview%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-393113%22%20slang%3D%22en-US%22%3E%3CP%3EFrom%20a%20support%20perspective%2C%20having%20a%20high-level%20view%20on%20a%20bot%20solution%20helps%20a%20lot%20figuring%20out%20the%20possible%20causes%20for%20issues%2C%20or%20at%20least%20isolate%20better%20where%20they%20happen.%3C%2FP%3E%0A%3CP%3EWith%20Bot%20Framework%2C%20a%20bot%20application%20is%20simply%20a%20REST%20endpoint%2C%20which%20makes%20use%20of%20Bot%20Framework%20SDK%20libraries%20for%20several%20different%20languages%2C%20including%20C%23%2C%20NodeJS%2C%20JavaScript%20and%20Python.%20It%20is%20an%20application%20to%20drive%20the%20bot%20logic.%20Since%20the%20application%20has%20no%20UI%2C%20a%20user%20engaging%20the%20bot%20logic%20will%20have%20to%20use%20other%20means%20(or%20channels)%2C%20with%20the%20help%20of%20Azure%20Connector%20Service.%3C%2FP%3E%0A%3CP%3EIn%20fact%2C%20we%E2%80%99re%20talking%20at%20least%203%20sides%2C%203%20applications%20that%20are%20%E2%80%9Ctalking%E2%80%9D%20via%20web%20requests.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EThe%20bot%20%3CSTRONG%3Eclient%3C%2FSTRONG%3E%3A%20the%20application%20or%20mean%20for%20a%20user%20to%20engage%20in%20a%20bot%20conversation%3B%3C%2FLI%3E%0A%3CLI%3EThe%20bot%20%3CSTRONG%3Elogic%3C%2FSTRONG%3E%20endpoint%2C%20the%20code%20executed%20to%20fulfill%20the%20bot%E2%80%99s%20functionality%3B%3C%2FLI%3E%0A%3CLI%3EThe%20bot%20%3CSTRONG%3Econnector%3C%2FSTRONG%3E%3A%20a%20proxy%20or%20hub%20conducting%20messages%20from%20client%20to%20%E2%80%9Cbot%20logic%E2%80%9D%20and%20then%20replies%20back%20from%20bot%20to%20the%20client.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%20style%3D%22text-align%3A%20center%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101371i356328B675AD04E0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Slide1%2C%20Bot%20messaging%20diagram.PNG%22%20title%3D%22Slide1%2C%20Bot%20messaging%20diagram.PNG%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EThe%20who%20and%20what%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThe%20bot%20solution%20may%20offer%20users%20various%20conversational%20channels%20(clients)%20to%20engage%20the%20bot%2C%20such%20as%20Facebook%20messenger%20or%20SMS%20messages.%20A%20custom%20client%20may%20be%20created%20too%20with%20the%20DirectLine%20channel%2C%20using%20the%20DirectLine%20Client%20SDK%20Libraries.%3C%2FP%3E%0A%3CP%3EThe%20bot%20logic%20is%20where%20the%20developer%20will%20deploy%20the%20custom%20bot%20code%2C%20which%20is%20the%20actual%20functionality.%20It%20may%20be%20hosted%20either%20as%20an%20Azure%20App%20Service%2C%20or%20as%20any%20other%20on-premises%20Web%20application%2C%20as%20long%20as%20its%20endpoint%20is%20publicly%20reachable%20by%20calls%20from%20the%20%E2%80%9CConnector%E2%80%9D.%3C%2FP%3E%0A%3CP%3EThe%20%E2%80%9CConnector%E2%80%9D%20service%20is%20a%20global%20application%20owned%20and%20operated%20by%20Microsoft%2C%20hosted%20on%20Azure%20nodes%20spread%20geographically%20to%20ensure%20scalability%20and%20fast%20response.%20It%20will%20%E2%80%9Ctalk%E2%80%9D%20with%20the%20client%20and%20the%20logic%2C%20providing%20proxy%20services%20in%20a%20conversational%20way.%20While%20relaying%20messages%2C%20it%20will%20also%20transform%20their%20%E2%80%9Cenvelopes%E2%80%9D%3A%20from%20a%20channel-specific%20message%20format%20to%20a%20consistent%20format%20used%20by%20the%20bot%20framework.%3C%2FP%3E%0A%3CP%3ECommunication%20between%20the%20connector%20service%20and%20the%20bot%20logic%20endpoint%20is%20ensured%20via%20HTTP%20POST%20requests.%20Each%20message%20from%20user%20or%20reply%20message%20from%20bot%20will%20become%20a%20POST%20request%20between%20connector%20and%20bot.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1681612358%22%20id%3D%22toc-hId-1705684421%22%3ESecurity.%20Creating%20bot%3C%2FH2%3E%0A%3CP%3EThe%20HTTP%20requests%20between%20connector%20and%20logic%20are%20secured%2C%20authenticated%3B%20they%20bear%20a%20specific%20HTTP%20header%20holding%20a%20token%20issued%20by%20Azure%20Active%20Directory.%20Somehow%2C%20Azure%20AD%20must%20be%20aware%20of%20both%20connector%20and%20the%20bot%20logic%2C%20because%20both%20of%20them%20%E2%80%9Coutsource%E2%80%9D%20authentication%20to%20Azure%20AD.%3C%2FP%3E%0A%3CP%3EWhen%20creating%20a%20bot%20in%20the%20Azure%20portal%2C%20we%20may%20choose%20from%20a%20couple%20of%20provisioning%20templates%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EBot%20Channel%20Registration%3C%2FSTRONG%3E%3A%20Assumes%20that%20the%20logic%2C%20the%20bot%20API%20app%2C%20will%20be%20hosted%20on%20premises.%20So%2C%20this%20template%2C%20to%20put%20it%20simple%2C%20will%20register%20a%20new%20bot%20with%20the%20connector%20service%2C%20adding%20an%20application%20ID%20entry%20into%20the%20Azure%20AD%20tenant%20that%20the%20connector%20trusts.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EWeb%20App%20Bot%3C%2FSTRONG%3E%3A%20It%20is%20a%20bot%20channel%20registration%20plus%20a%20few%20things%2C%20considering%20that%20the%20bot%20logic%20will%20be%20hosted%20in%20Azure%2C%20among%20which%3A%3CUL%3E%0A%3CLI%3EProvisions%20an%20Azure%20App%20Service%20where%20the%20bot%20logic%20will%20be%20executed%3B%3C%2FLI%3E%0A%3CLI%3ECreates%20(or%20assumes)%20an%20entry%20in%20the%20Azure%20AD%20tenant%20of%20the%20subscription%20where%20the%20bot%20connector%20service%20is%20provisioned%3B%3C%2FLI%3E%0A%3CLI%3EDeploys%20some%20bot%20template%20code%20in%20the%20Azure%20App%20Service%20created%2C%20after%20populating%20config%20files%3B%20just%20a%20starter%20for%20the%20bot%20logic%20to%20be%20further%20developed.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EFunctions%20Bot%3C%2FSTRONG%3E%3A%20Very%20similar%20to%20the%20Web%20App%20Bot%20template%2C%20except%20that%20the%20logic%20will%20be%20hosted%20in%20a%20server%3CEM%3Eless%3C%2FEM%3E%20Azure%20Functions%20service.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EIt%20is%20important%2C%20when%20creating%20bots%2C%20to%20choose%20Application%20Insights%20or%20at%20least%20some%20other%20monitoring%20solution%3B%20I%E2%80%99ll%20detail%20why%20shortly.%20Also%2C%20enabling%20Application%20Insights%20needs%20an%20extra%20step%3B%20see%20below%20in%20the%20Monitoring%20section.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--870544603%22%20id%3D%22toc-hId--846472540%22%3EThe%20Gateway%20Timeout%20issue%3C%2FH2%3E%0A%3CP%3EThe%20connector%2C%20acting%20as%20a%20proxy%20between%20client%20and%20logic%2C%20has%20some%20expectations.%20When%20these%20are%20not%20met%2C%20issues%20are%20recorded.%3C%2FP%3E%0A%3CP%3EOne%20of%20the%20expectations%20is%20that%20the%20logic%20will%20acknowledge%20a%20user%20message%20in%20no%20more%20than%2015%20seconds%2C%20a%20threshold%20hardwired%20in%20the%20connector%20that%20the%20developer%20cannot%20configure.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20center%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101382iB9EEE4999DEA370A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Slide2%2C%20Bot%20time-out.PNG%22%20title%3D%22Slide2%2C%20Bot%20time-out.PNG%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EWhy%20the%20GatewayTimeout%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThe%20connector%20will%20relay%20the%20user%20message%20as%20a%20POST%20request%2C%20expecting%20an%20HTTP%20response%20from%20the%20logic%20with%20a%20202(Accepted)%20status%20code.%3C%2FP%3E%0A%3CP%3EHowever%2C%20before%20the%20logic%20can%20acknowledge%20the%20user%20message%20with%20the%20%E2%80%9C202%E2%80%9D%20response%2C%20it%20will%20usually%20try%20to%20reply%20to%20the%20user%2C%20via%20the%20connector%2C%20with%20its%20own%20POST%20message%20to%20the%20connector.%20In%20many%20cases%2C%20such%20a%20reply%20will%20involve%20calls%20made%20to%20dependency%20services%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EAzure%20Active%20Directory%3A%3CBR%20%2F%3ESince%20replies%20from%20the%20bot%20logic%20are%20authenticated%20POST%20requests%2C%20the%20authentication%20header%20must%20contain%20a%20token%20from%20the%20Azure%20AD.%3C%2FLI%3E%0A%3CLI%3EBot%20state%2C%20conversation%20context%3A%3CBR%20%2F%3EWhen%20responding%20to%20a%20message%2C%20the%20bot%20logic%20usually%20has%20to%20correlate%20that%20message%20with%20a%20conversation%2Fuser%20context%2C%20maybe%20reply%20after%20consulting%20some%20state%20information.%3C%2FLI%3E%0A%3CLI%3EOther%20cognitive%20services%3A%3CBR%20%2F%3EThe%20bot%20logic%20may%20rely%20on%20a%20QnA%2FFAQ%20repository%2C%20language%20understanding%20(LUIS)%2C%20image%20or%20voice%20recognition%2C%20etc.%3C%2FLI%3E%0A%3CLI%3EBot-specific%20resources%3A%3CBR%20%2F%3ESometimes%20a%20reply%20involves%20querying%20some%20database%20or%20performing%20transactions%20in%20other%20systems.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%20style%3D%22text-align%3A%20center%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101383iDA3FCDD58329AD67%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Slide3%2C%20Bot%20dependencies.PNG%22%20title%3D%22Slide3%2C%20Bot%20dependencies.PNG%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EDependencies%20may%20add%20latency%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EAll%20these%20dependencies%20will%20add%20to%20latency.%20But%20there%20is%20more.%20As%20a%20web%20application%2C%20the%20bot%20logic%20may%20be%20%E2%80%9Casleep%E2%80%9D%20due%20to%20idleness%20(no%20requests%20received%20in%20a%20while)%2C%20or%20it%20may%20restart%20due%20to%20configuration%20changes.%20With%20Asp.Net%20Core%20or%20NodeJS%2C%20a%20separate%20process%20from%20IIS%20will%20actually%20execute%20the%20app%3B%20yet%20more%20latency.%3C%2FP%3E%0A%3CP%3EThe%2015-seconds%20threshold%20may%20be%20easily%20exceeded%2C%20so%20all%20these%20aspects%20must%20be%20considered%20when%20thinking%20of%20performance.%20I%E2%80%99d%20recommend%20that%20the%20bot%20replies%20ASAP%20to%20the%20user%2C%20even%20if%20the%20reply%20is%20simply%20something%20like%20%E2%80%9CI%20got%20you%2C%20allow%20me%20some%20time%E2%80%9D%3B%20then%20the%20full%20answer%20may%20be%20provided.%20Such%20a%20fast%20reply%20may%20also%20be%20a%20simple%20activity%20update%20sent%20by%20bot%20to%20the%20connector.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-872265732%22%20id%3D%22toc-hId-896337795%22%3EMonitoring%3C%2FH2%3E%0A%3CP%3EIn%20the%20end%2C%20lots%20of%20things%20may%20have%20to%20happen%20before%20the%20bot%20can%20reply%20to%20the%20user.%20So%2C%20there%20are%20lots%20of%20points%20where%20things%20may%20go%20wrong.%20How%20does%20one%20trace%20an%20error%20or%20a%20latency%2C%20when%20the%20bot%20logic%20may%20be%20a%20%E2%80%9Cblack-box%E2%80%9D%3F%20How%20can%20we%20%E2%80%9Csee%E2%80%9D%20inside%20the%20execution%3F%3C%2FP%3E%0A%3CP%3EWhile%20the%20web%20server%20logs%20or%20application%20logs%20may%20offer%20some%20information%2C%20the%20troubleshooting%20or%20performance%20tuning%20at%20times%20need%20to%20relay%20on%20more%20details.%20We%20need%20a%20monitoring%20solution.%20Enter%20Application%20Insights.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20center%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101386iF2924075321706A5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Slide5%2C%20Bot-comprehensive%20diagram.PNG%22%20title%3D%22Slide5%2C%20Bot-comprehensive%20diagram.PNG%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EApplication%20Insights%20fits%20in%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EWhen%20creating%20a%20bot%20in%20the%20Azure%20portal%2C%20the%20wizard%20does%20offer%20the%20option%20to%20employ%20Application%20Insights%20as%20monitoring%20solution%2C%20and%20it%20even%20places%20the%20needed%20configuration%20info%20for%20the%20bot%20logic.%20But%20there%20is%20a%20catch%3A%20the%20bot%20logic%2C%20the%20app%2C%20does%20not%20log%20into%20Application%20Insights%20by%20default%3B%20an%20extra%20step%20is%20need.%3C%2FP%3E%0A%3CP%3EThe%20bot%20logic%20must%20include%20the%20right%20NuGet%20or%20NPM%20packages%3B%20and%20these%20will%20report%20on%20exceptions%2C%20for%20instance%2C%20by%20default%20%E2%80%93%20no%20extra%20code%20needs%20be%20added%20by%20the%20developer.%20Other%20telemetry%20info%20that%20Application%20Insights%20can%20track%20will%20need%20extra%20code%2C%20if%20you%20want%20to%20monitor%20custom%20events%20or%20metrics.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EDo%20enable%20Application%20Insights!%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EI%20found%20there%20is%20an%20easier%20way%20to%20enable%20it%20from%20the%20portal%2C%20for%20the%20App%20Service%20or%20Azure%20Functions%20instance%2C%20illustrated%20below%3A%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20center%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20981px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101385iED5E10FF485642FF%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Enable%20Application%20Insights.png%22%20title%3D%22Enable%20Application%20Insights.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EQuickly%20enable%20Application%20Insights%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBest%20of%20luck!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-393113%22%20slang%3D%22en-US%22%3E%3CP%3EGet%20some%20schematics%20about%20a%20bot%20solution%2C%20have%20a%20better%20picture%20on%20what%20is%20involved%2C%20how%20things%20work%20together.%20Seeing%20how%20apps%20work%20together%20helps%20a%20lot%20figuring%20out%20where%20to%20start%20the%20troubleshooting%2C%20what%20to%20investigate.%3C%2FP%3E%3C%2FLINGO-TEASER%3E

From a support perspective, having a high-level view on a bot solution helps a lot figuring out the possible causes for issues, or at least isolate better where they happen.

With Bot Framework, a bot application is simply a REST endpoint, which makes use of Bot Framework SDK libraries for several different languages, including C#, NodeJS, JavaScript and Python. It is an application to drive the bot logic. Since the application has no UI, a user engaging the bot logic will have to use other means (or channels), with the help of Azure Connector Service.

In fact, we’re talking at least 3 sides, 3 applications that are “talking” via web requests.

  1. The bot client: the application or mean for a user to engage in a bot conversation;
  2. The bot logic endpoint, the code executed to fulfill the bot’s functionality;
  3. The bot connector: a proxy or hub conducting messages from client to “bot logic” and then replies back from bot to the client.

Slide1, Bot messaging diagram.PNGThe who and what

The bot solution may offer users various conversational channels (clients) to engage the bot, such as Facebook messenger or SMS messages. A custom client may be created too with the DirectLine channel, using the DirectLine Client SDK Libraries.

The bot logic is where the developer will deploy the custom bot code, which is the actual functionality. It may be hosted either as an Azure App Service, or as any other on-premises Web application, as long as its endpoint is publicly reachable by calls from the “Connector”.

The “Connector” service is a global application owned and operated by Microsoft, hosted on Azure nodes spread geographically to ensure scalability and fast response. It will “talk” with the client and the logic, providing proxy services in a conversational way. While relaying messages, it will also transform their “envelopes”: from a channel-specific message format to a consistent format used by the bot framework.

Communication between the connector service and the bot logic endpoint is ensured via HTTP POST requests. Each message from user or reply message from bot will become a POST request between connector and bot.

Security. Creating bot

The HTTP requests between connector and logic are secured, authenticated; they bear a specific HTTP header holding a token issued by Azure Active Directory. Somehow, Azure AD must be aware of both connector and the bot logic, because both of them “outsource” authentication to Azure AD.

When creating a bot in the Azure portal, we may choose from a couple of provisioning templates:

  • Bot Channel Registration: Assumes that the logic, the bot API app, will be hosted on premises. So, this template, to put it simple, will register a new bot with the connector service, adding an application ID entry into the Azure AD tenant that the connector trusts.
  • Web App Bot: It is a bot channel registration plus a few things, considering that the bot logic will be hosted in Azure, among which:
    • Provisions an Azure App Service where the bot logic will be executed;
    • Creates (or assumes) an entry in the Azure AD tenant of the subscription where the bot connector service is provisioned;
    • Deploys some bot template code in the Azure App Service created, after populating config files; just a starter for the bot logic to be further developed.
  • Functions Bot: Very similar to the Web App Bot template, except that the logic will be hosted in a serverless Azure Functions service.

It is important, when creating bots, to choose Application Insights or at least some other monitoring solution; I’ll detail why shortly. Also, enabling Application Insights needs an extra step; see below in the Monitoring section.

The Gateway Timeout issue

The connector, acting as a proxy between client and logic, has some expectations. When these are not met, issues are recorded.

One of the expectations is that the logic will acknowledge a user message in no more than 15 seconds, a threshold hardwired in the connector that the developer cannot configure.

Slide2, Bot time-out.PNGWhy the GatewayTimeout

The connector will relay the user message as a POST request, expecting an HTTP response from the logic with a 202(Accepted) status code.

However, before the logic can acknowledge the user message with the “202” response, it will usually try to reply to the user, via the connector, with its own POST message to the connector. In many cases, such a reply will involve calls made to dependency services:

  • Azure Active Directory:
    Since replies from the bot logic are authenticated POST requests, the authentication header must contain a token from the Azure AD.
  • Bot state, conversation context:
    When responding to a message, the bot logic usually has to correlate that message with a conversation/user context, maybe reply after consulting some state information.
  • Other cognitive services:
    The bot logic may rely on a QnA/FAQ repository, language understanding (LUIS), image or voice recognition, etc.
  • Bot-specific resources:
    Sometimes a reply involves querying some database or performing transactions in other systems.

Slide3, Bot dependencies.PNGDependencies may add latency

All these dependencies will add to latency. But there is more. As a web application, the bot logic may be “asleep” due to idleness (no requests received in a while), or it may restart due to configuration changes. With Asp.Net Core or NodeJS, a separate process from IIS will actually execute the app; yet more latency.

The 15-seconds threshold may be easily exceeded, so all these aspects must be considered when thinking of performance. I’d recommend that the bot replies ASAP to the user, even if the reply is simply something like “I got you, allow me some time”; then the full answer may be provided. Such a fast reply may also be a simple activity update sent by bot to the connector.

Monitoring

In the end, lots of things may have to happen before the bot can reply to the user. So, there are lots of points where things may go wrong. How does one trace an error or a latency, when the bot logic may be a “black-box”? How can we “see” inside the execution?

While the web server logs or application logs may offer some information, the troubleshooting or performance tuning at times need to relay on more details. We need a monitoring solution. Enter Application Insights.

 

Slide5, Bot-comprehensive diagram.PNGApplication Insights fits in

When creating a bot in the Azure portal, the wizard does offer the option to employ Application Insights as monitoring solution, and it even places the needed configuration info for the bot logic. But there is a catch: the bot logic, the app, does not log into Application Insights by default; an extra step is need.

The bot logic must include the right NuGet or NPM packages; and these will report on exceptions, for instance, by default – no extra code needs be added by the developer. Other telemetry info that Application Insights can track will need extra code, if you want to monitor custom events or metrics.

Do enable Application Insights!

I found there is an easier way to enable it from the portal, for the App Service or Azure Functions instance, illustrated below:

Enable Application Insights.pngQuickly enable Application Insights

 

Best of luck!