Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

botbuilder-instrumentation

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

botbuilder-instrumentation

Follow these steps:

  • 1.0.14
  • npm
  • Socket score

Version published
Weekly downloads
3.6K
decreased by-0.94%
Maintainers
2
Weekly downloads
 
Created
Source

Adding Logging to an Existing bot

Follow these steps:

Connect to Application Insights

  1. Create an Application Insights service under your subscription.
  2. Use the Instrumentation Key inside your bot registration page under Instrumentation key.
  3. Under the App Insights serivce, go to API Access and copy Application ID
  4. Under the App Insights serivce, go to API Access >> New Key with Read permissions and copy Api Key.

Connect to Cognitive Services

Create a new Sentiment Analisys Service under Cognitive Services. When creating the service, make sure to mark Text Analytics - Preview.

Setting Environment Variables

APPINSIGHTS_INSTRUMENTATIONKEY={App Insights Instrumentation Key}
CG_SENTIMENT_KEY={Cognitive Services Text Analytics Key}

Connecting to Code

var instrumentation = require('botbuilder-instrumentation');

// Setting up advanced instrumentation
let logging = new instrumentation.BotFrameworkInstrumentation({ 
  instrumentationKey: process.env.APPINSIGHTS_INSTRUMENTATIONKEY,
  sentimentKey: process.env.CG_SENTIMENT_KEY,
});
logging.monitor(bot);

Using mutiple instrumnetation keys

var instrumentation = require('botbuilder-instrumentation');

// Setting up advanced instrumentation
let logging = new instrumentation.BotFrameworkInstrumentation({ 
  instrumentationKey: ["main insturmnation key","secondary instumentation key"],
  sentimentKey: process.env.CG_SENTIMENT_KEY,
});
logging.monitor(bot);

Sending logs for QnA maker service

var instrumentation = require('botbuilder-instrumentation');

// Setting up advanced instrumentation
let logging = new instrumentation.BotFrameworkInstrumentation({ 
  instrumentationKey: ["main insturmnation key","secondary instumentation key"],
  sentimentKey: process.env.CG_SENTIMENT_KEY,
});
logging.monitor(bot);

//hook into the result function of QNA to extract relevant data for logging.
loggins.trackQNAEvent(context, userQuery, kbQuestion, kbAnswer, score);
//You can see a working sample in [https://github.com/Microsoft/BotBuilder-CognitiveServices/tree/master/Node/samples/QnAMakerWithFunctionOverrides](https://github.com/Microsoft/BotBuilder-CognitiveServices/tree/master/Node/samples/QnAMakerWithFunctionOverrides)

Sending custom event data

var instrumentation = require('botbuilder-instrumentation');

// Setting up advanced instrumentation
let logging = new instrumentation.BotFrameworkInstrumentation({ 
  instrumentationKey: ["main insturmnation key","secondary instumentation key"],
  sentimentKey: process.env.CG_SENTIMENT_KEY,
});
logging.monitor(bot);
let customEventName = 'myCustomEventName'; //This will show up as the event name in Application Insights.
let customEventData = { customeDataA: 'customValueA', customDataB: 3 };
logging.trackCustomEvent(context, customEventName, customEventData); //Custom key-value data. It will be avaiable under the customDimentions column in Application Insights.

You can see a working sample in https://github.com/morsh/bot-with-instrumentation

FAQs

Package last updated on 14 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc