Giter VIP home page Giter VIP logo

botbuilder-utils-js's Introduction

Botbuilder Utils for JavaScript

This repo contains sample code that can be used to enhance a v4 Microsoft Bot Framework bot running NodeJS. It has been tested against version 4.0.6.

Packages come with no guarantee of support or updates.

Packages

The following packages are provided as sample code only, and so are not published to npm. To use them in your bot, follow the instructions in the respective READMEs:

  1. botbuilder-transcript-cosmosdb
  2. botbuilder-transcript-app-insights
  3. botbuilder-feedback
  4. botbuilder-http-test-recorder

Questions and Contact

If you have a question or would like to contact the development team, please open an issue in this repo.

Contributing

The botbuilder-utils team is currently only accepting bug fixes, not feature requests. If you spot a bug, please open an issue, and if possible, open a PR.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

botbuilder-utils-js's People

Contributors

ctstone avatar microsoft-github-policy-service[bot] avatar roalexan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

botbuilder-utils-js's Issues

Add an option to disable 'dismissAction'

Right now there is the ability to customize the text for the "feedback action" via

{
  /** Text to show on button that allows user to hide/ignore the feedback request. Default value is `'dismiss'` */
  dismissAction?: FeedbackAction
}

It seems to me that some bot framework developers might not want to show this button at all, since users can also ignore feedback by just not clicking any of the buttons and continuing their conversation. This might be a slightly simpler interface (one less button) that we want to enable for our bot framework developers.

BTW, I tried setting the text as an empty string, but it then resorts to the default ("dismiss").

For test recorder rec:stop followed by rec:start throws exception

The bot server needs to be restarted to restart.

Here's an example exception:

Error: Nock recording already in progress
    at Object.record [as rec] (C:\microsoft\repos\bots\samples\luisbot\javascript\node_modules\nock\lib\recorder.js:209:11)
    at HttpTestRecorder.<anonymous> (C:\microsoft\repos\bots\samples\luisbot\javascript\node_modules\botbuilder-http-test-recorder\dist\index.js:112:33)
    at Generator.next (<anonymous>)
    at C:\microsoft\repos\bots\samples\luisbot\javascript\node_modules\botbuilder-http-test-recorder\dist\index.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (C:\microsoft\repos\bots\samples\luisbot\javascript\node_modules\botbuilder-http-test-recorder\dist\index.js:3:12)
    at HttpTestRecorder.startRecording (C:\microsoft\repos\bots\samples\luisbot\javascript\node_modules\botbuilder-http-test-recorder\dist\index.js:110:16)
    at HttpTestRecorder.<anonymous> (C:\microsoft\repos\bots\samples\luisbot\javascript\node_modules\botbuilder-http-test-recorder\dist\index.js:51:33)
    at Generator.next (<anonymous>)
    at C:\microsoft\repos\bots\samples\luisbot\javascript\node_modules\botbuilder-http-test-recorder\dist\index.js:7:71

Readme Requirements - Check our Readme's comply

  • Starts with a one-line description that explains what the project is about, who might be interested in it, what language it is written in, and how it might be different from similar projects.

  • Includes a list of features and limitations.

  • States the goals and scope of the project to help set expectations and filter proposed changes down the line.

  • Includes the current status (for example, proof of concept, used in production, active development, orphaned, and so on.)

  • Includes a description of the kind of environment required to run the software and instructions for setting it up.

  • Includes a link to the Microsoft Open Source Code of Conduct. https://opensource.microsoft.com/codeofconduct.

  • Clearly states the external dependencies and directions for installing them.

  • Includes a high-level development roadmap or link to open issues/milestones.

  • Explicitly asks for contributions, if you want them, with information on how to contribute and/or a link to a CONTRIBUTING.md file.

  • Includes a pointer to where questions should be asked and how the development team can be contacted.

  • Includes information on how to privately report security vulnerabilities (to MSRC).

You cantidad postenta some sample?

Im trying this code but i have trouble because when responded the question not trigger the trace activity type when storing record.

Thanks

HTTP test playback requires that I manually encode the capture for it to match the request

I first ran a project based on the code snippet here to record a response from LUIS (a projectplanner app, based on the AI CAT all-hands). The response, luis1.txt:
has the following:

"body": "Show me all docs for Oracle"

Note the lack of encoding. Then for the playback, I ran a project based on the code snippet here, and it gave me the following error:

(node:16132) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'statusCode' of undefined
    at LuisRecognizer.prepareErrorMessage (C:\microsoft\repos\bots\samples\testplayback\javascript\node_modules\botbuilder-ai\lib\luisRecognizer.js:120:32)
    at luisClient.prediction.resolve.then.catch.error (C:\microsoft\repos\bots\samples\testplayback\javascript\node_modules\botbuilder-ai\lib\luisRecognizer.js:93:22)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

I printed out the return value of playback.load, and saw it had the following:

"body": "\"Show me all docs for Oracle\""

Note the encoding. So, in order to get this test to run, I had to manually open up my recording JSON and manually add this encoding to make it work.

Feedback middleware suggestions

I have a couple of suggestions for improving your Feedback middleware. The primary one being that you should pass a StatePropertyAccessor to your middlewares constructor instead of a ConversationState object. This will eliminate the need to extend the TurnContext like you're doing and generally simplify working with your feedback record. So your middlewares constructor and onTurn() should look something like this:

export class FeedbackMiddleware implements Middleware {
    constructor(private feedbackProp: StatePropertyAccessor<FeedbackRecord>, private options?: FeedbackOptions) { }

    async onTurn(context: TurnContext, next: () => Promise<void>): Promise<void> {
        // Get feedback record
        const record = await this.feedbackProp.get(context);
        if (record) {
            // ... do something ...
        }
    }
}

You can call await this.feedbackProp.set(context, record) to initialize the record and await this.feedbackProp.delete(context) to clear it.

And if you want to save the property accessor on your TurnContext so that you can access it from your static methods you should use the TurnContext.turnState map instead of extending the context object. Updating the sample above you would do this:

const feedbackKey = Symbol('feedback');

export class FeedbackMiddleware implements Middleware {
    constructor(private feedbackProp: StatePropertyAccessor<FeedbackRecord>, private options?: FeedbackOptions) { }

    async onTurn(context: TurnContext, next: () => Promise<void>): Promise<void> {
        // Save feedback prop to turn context
        context.turnState.set(FeedbackKey, this.feedbackProp);

        // Get feedback record
        const record = await context.turnState.get(feedbackKey).get(context);
        if (record) {
            // ... do something ...
        }
    }
}

The Symbol() just helps ensure that you don't have naming collisions with other components caching stuff to the TurnContext.

Transcript logging is not pushing Dialog information

Hi,
This is a great use case.

I can see the Bot, Luis and User information in the Application Insight Log.

How can I add the dialog information with these ?
I am managing Dialog state with cosmos DB but I what if we want to log each step of Dialog.
Any guidance?

Typo and broken link

aheres the Bot Framework Activity Schema.

typo: aheres
broken link: the link following it.

Figure out way to automate finding the correct playback directory

As of now, we're instructing our users to always construct HttpTestPlayback with 'testDataDirectory', otherwise it defaults to, for example: C:\microsoft\repos\bots\samples\testplayback\javascript\node_modules\mocha\bin\test\data\

However, it might be nice if an empty constructor could be used, and the code defaults to the directory of the project, not 'node_modules\mocha\bin'.

Required Header authorization is missing, TranscriptLoggerMiddleware logActivity failed

Hello,

I am trying to do transcript logging on Echo Bot in Cosmos DB, but it is giving the below error.
Am I missing some configuration ?

TranscriptLoggerMiddleware logActivity failed: "{"code":"Unauthorized","message":"Required Header authorization is missing. Ensure a valid Authorization token is passed.\r\nActivityId: a4d5a91f-b1cf-499f-ae48-ecbb65f89c6c, Microsoft.Azure.Documents.Common/2.5.1"}"
Error: {"code":"Unauthorized","message":"Required Header authorization is missing. Ensure a valid Authorization token is passed.\r\nActivityId: a4d5a91f-b1cf-499f-ae48-ecbb65f89c6c, Microsoft.Azure.Documents.Common/2.5.1"}
at created (D:\Learning\Projects\msbot-samples\botbuilder-utils-js\packages\botbuilder-transcript-cosmosdb\dist\cosmosdb.js:82:16)
at client.createDatabase (D:\Learning\Projects\msbot-samples\botbuilder-utils-js\packages\botbuilder-transcript-cosmosdb\dist\cosmosdb.js:13:48)
at D:\ANISHDATA\Learning\Azure Bots\botbuilder-samples\samples\javascript_nodejs\02.echo-bot\node_modules\documentdb\lib\documentclient.js:2200:21
at D:\ANISHDATA\Learning\Azure Bots\botbuilder-samples\samples\javascript_nodejs\02.echo-bot\node_modules\documentdb\lib\retryUtility.js:97:32
at Base.defineClass.shouldRetry.shouldRetry (D:\ANISHDATA\Learning\Azure Bots\botbuilder-samples\samples\javascript_nodejs\02.echo-bot\node_modules\documentdb\lib\defaultRetryPolicy.js:98:20)
at D:\ANISHDATA\Learning\Azure Bots\botbuilder-samples\samples\javascript_nodejs\02.echo-bot\node_modules\documentdb\lib\retryUtility.js:92:29
at onComplete (D:\ANISHDATA\Learning\Azure Bots\botbuilder-samples\samples\javascript_nodejs\02.echo-bot\node_modules\documentdb\lib\request.js:98:9)
at IncomingMessage. (D:\ANISHDATA\Learning\Azure Bots\botbuilder-samples\samples\javascript_nodejs\02.echo-bot\node_modules\documentdb\lib\request.js:120:24)
at IncomingMessage.emit (events.js:194:15)
at IncomingMessage.EventEmitter.emit (domain.js:441:20)

Flow not right when specifying specific values for 'promptFreeForm'

this works as expected: const promptFreeForm: boolean = true;
this does not: const promptFreeForm: string[] = ['3'];

this is for the case when I've also set:
const feedbackActions: FeedbackAction[] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'];

When I click '2', it shows the feedbackResponse when it shouldn't. I only specified free-form feedback for '3'.

when I click '3', it correctly asks for feedback, but after typing the feedback, it asks for feedback again and then shows the feedbackActions. I select an action, and it displays the feedbackResponse.

Shipping Tasks

  • Double check/confirm that all sensitive material has been removed from commit history, issues, and pull requests.

  • Make the repository public.

  • Tweet about it from your personal account.

  • If it makes sense, blog about this project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.