JSPM

botbuilder-facebook-quick-replies

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 5
    • Score
      100M100P100Q24694F
    • License ISC

    Provides an easy way to add Facebook Quick Replies to a message from bot to user with just one line of code.

    Package Exports

    • botbuilder-facebook-quick-replies

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (botbuilder-facebook-quick-replies) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Facebook Quick Replies for Microsoft Bot Framework

    ###Short sample

    const quick = require('botbuilder-facebook-quick-replies');
    
    let message = new builder.Message(session)
      .text('I am a bot. Press buttons below.');
    quick.replies(message, ['Yes', 'No']);
    session.send(message);

    ###What's it for? This package provides a way to add Facebook Quick Replies to your bot's message. It works with bots written in Node.js using Microsoft Bot Framework (see the botbuilder package).

    It supports plain-text buttons, as well as buttons with different text and underlying value. Images on quick reply buttons are not yet supported.

    Most common usage

    At the top of your file, add:

    const builder = require('botbuilder');
    const quick = require('botbuilder-facebook-quick-replies');

    Then, when you are creating a message within a dialog:

    // Create a plaintext message as usual:
    let message = new builder.Message(session)
      .text('What do you think?');
    
    // Now add the quick replies:
    quick.replies(message, ['Cool!', 'Not bad!']);
    
    // And send it to the user:
    session.send(message);

    This also works fine when your message contains attachments (like HeroCards, rather than just plain text).

    When the bot must receive a different value from what the user sees

    This is helpful when the button must tell the bot some additional parameters.

    // Create a plaintext message as usual:
    let message = new builder.Message(session)
      .text('Do you want to buy this product?');
    
    // Now add the quick replies:
    quick.replies(message, [
      { text: 'Buy Now', value: 'BUY #81571' },
      { text: 'Save for later', value 'SAVE #81571' },
    ]);
    
    // And send it to the user:
    session.send(message);

    In this case, when the user clicks the Buy Now button, the message that the bot will actually receive is 'BUY #81571'.

    ###Comments and suggestions If you have any comments, contact me here: https://github.com/catcher-in-the-try/