1.1.1 • Published 7 years ago

botbuilder-quickreplies v1.1.1

Weekly downloads
17
License
MIT
Repository
github
Last release
7 years ago

BotBuilder Facebook QuickReplies

Library to add simple support for Facebook's quick replies to bots developed using Microsoft Bot Framework (botbuilder).

Description

This library simplies the task of supporting Facebook Messengers 'quick replies' functionality, it adds the ability to add quick replies to any outgoing message as well as supplying the required middleware for extracting the response payloads which indicate the correct response. It ensures that replies made using quick responses with facebook are able to be recognised and handled by recognisers such as LUIS.

Quick Replies

Usage

Install...

npm install botbuilder-quickreplies --save

Apply the required middleware to the bot...

var quickReplies = require('botbuilder-quickreplies');
var bot = new builder.UniversalBot(connector, function (session) {
    session.send("Hello I am a chatbot.");
});

// Set the middleware.
bot.use(quickReplys.QuickRepliesMiddleware);

Creating quick responses...

// Create a message with some text.
var message = new builder.Message(session).text('Some text');

// Add some quick replies.
message = quickReplies.AddQuickReplies(session, message, [
    new quickReplies.QuickReplyText(session, 'This is my title', 'This is my message'),
    new quickReplies.QuickReplyText(session, 'This is another title', 'This is other message', 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Button_Icon_Blue.svg/768px-Button_Icon_Blue.svg.png') // with optional image
]);

// Send the message.
session.send(message);

Location Quick Replies

The library also provides a custom prompt that can be used to request the users location using a quick reply...

// Register the quick replies prompt with the bot.
quickReplies.LocationPrompt.create(bot);

// Use prompt in a dialog..
bot.dialog('/asklocation, [
    function (session, args, next) {
        quickReplies.LocationPrompt.beginDialog(session);
    },
    function (session, args, next) {
        if (args.response) {
            var location = args.response.entity;
            session.send(`Your location is : ${location.title}, Longitude: ${location.coordinates.long}, Latitude: ${location.coordinates.lat}`);
        }
    }
])

Notes

The library will ensure that the quick responses are only added and handled by the bot if the conversation channel is Facebook, there is no need for additional checking.

1.1.1

7 years ago

1.1.0

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago