npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

botbuilder-telemetry

v1.0.3

Published

Microsoft Botbuilder telemetry package for analytics.

Downloads

19

Readme

botbuilder-telemetry

Build Status

Microsoft Botbuilder telemetry package for analytics. Allows bot session, incoming and outgoing messages, and LUIS recognizer to be captured and consumed. This payload can be sent to any endpoint desired.

Telemetry Included (predefined body payload)

botName                 // "Test-Bot"
userName                // "Kevin L."
userMessage             // "hello"
userMessageLength       // 5
userMessageTimestamp    // 2017-10-26T20:21:54.977Z
botResponse             // string[] ["Hello! I am your friendly bot."]
botResponseLength       // 10
botResponseTimestamp    // 2017-10-26T20:21:57.424Z
botResponseLatency      // 2447
currentDialog           // Object {dialog: "*:/", step: 0}
dialogStack             // string[] ["*:/", "*:/greeting"]
luisIntent              // "greeting"

Resources and Links

botbuilder-telemetry NPM package

botbuilder-telemetry Github

Microsoft Bot Builder SDK

Microsoft Bot Framework Documentation


Install

npm install botbuilder-telemetry

Usage

See examples folder for full app.js example.

Step 1: Configuration Object (Required)

This allows any object to be passed into the middleware, which will be available within the dataMutationFuncOrPromise(). This is useful if you wish to pass in default values to the body payload.

Ex. If you require the botVersion to be included in the payload, you can specify the version in the configObject and add this property onto the body within the dataMutationFuncOrPromise().

Note: If you would like LUIS intents included in the payload, you must pass in the recognizer (see example/app.js)

Note: If you do not require any config variables, create an empty object and pass it in.

var configObject = {
  'botVersion': 'v3',
  'luisRecognizer': luisRecognizer,
  'foo': 'bar'
}

Step 2: dataMutationFuncOrPromise (Optional)

This function or promise allows any processing and manipulation of the body payload, based on the predefined body payload, session, messages, recognizer and configObject.

messages is the object response from the bot to user containing the text, options, attachments and other relevant information.

Note: If dataMutationFuncOrPromise() is not defined, the predefined body payload will not be mutated and passed straight to the dataHandleFunction(), step 3.

function dataMutationFunction (body, session, messages, configObject) {
    // The bot version - Managed by the bot developer
    // Add bot version to body if passed in through configObject
    if (typeof configObject.botVersion === 'undefined') { 
      body.botVersion = configObject.botVersion 
    }

    // Restrict user message to 100 characters and update body
    if (body.userMessage.length > 100) { 
      body.userMessage = body.userMessage.substring(0, 100)
    }
  }

Step 3: dataHandleFunction (Required)

After the body has gone through dataMutationFuncOrPromise() (optional), it will be ready to send to any endpoint/api/storage you choose. You can create any request call within this function. This will be the last step in the sequence for this pipeline.

Ex. Sending the body to a test endpoint using node-fetch package.

function dataHandleFunction (body, session, messages, configObject) {
  fetch('https://testEndpoint.com', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/octet-stream',
      'Subscription-Key': process.env.apiKey
    },
    body: body
  }).then(response => {
    return response.json()
  }).then(json => {
  // Read response JSON here...
    console.log(json)
  })
}

Step 4: Apply middleware

This step is necessary to utilize this telemetry package. Make sure to apply the middleware right after you create your bot instance.

// from Microsoft botbuilder SDK
var bot = new builder.UniversalBot(connector) 

// Use botbuilder-telemetry package
bot = ApplyTelemetryMiddleware(bot, configObject, dataHandleFunction, dataMutationFuncOrPromise)

// ... Rest of your bot definition

Contributors

{
  "name": "Kevin Leung",
  "twitter": "https://twitter.com/kslhacks",
  "github": "https://github.com/KSLHacks/",
  "url": "http://KSLhacks.com/"
},
{
  "name": "Hao Luo",
  "twitter": "https://twitter.com/howlowck",
  "github": "https://github.com/howlowck",
  "url": "https://blog.lifeishao.com/"
},
{
  "name": "Heather Shapiro",
  "twitter": "https://twitter.com/microheather",
  "github": "https://github.com/heatherbshapiro",
  "url": "http://microheather.com/"
}