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-linebot-connector

v2.5.0

Published

line botframework builder

Downloads

20

Readme

botbuilder-linebot-connector

Microsoft Bot Framework V3 connector for Line office account

npm version dependencies Status

Features

  • ready for Microsoft Bot Framework V3
  • no need a registered bot on dev.botframework.com, but require a certified line developer account, go to apply trial account
  • depend on line and line-message-api packages
  • support receiving and sending almost any line message types
  • for express framework
  • serverless framework support - connector.serverlessWebhock(event)

LINE Messaging API for Node.js

About LINE Messaging API

Please refer to the official API documents for details.

  • Developer Documents - https://developers.line.me/messaging-api/overview
  • API Reference - https://devdocs.line.me/en/#messaging-api
  • Messaging API SDKs - https://developers.line.biz/en/docs/messaging-api/line-bot-sdk/

Installation

npm install --save botbuilder-linebot-connector

Donate; Buy me a Beer

If you want to thank me, or promote your Issue.

Donate

Sorry, but I have work and support for packages requires some time after work. I will be glad of your support and PR's.

Document

  • 使用 botframework + botbuilder-linebot-connector + serverless(AWS lambda) + botbuilder-mongodb-storage 連 mongodb cluster 開發 LineBot 入門 1 - http://wolke-codes.blogspot.tw/2018/02/botframework-botbuilder-linebot.html
  • 使用 botframework + botbuilder-linebot-connector + serverless(AWS lambda) + botbuilder-mongodb-storage 連 mongodb cluster 開發 LineBot 入門 2 - http://wolke-codes.blogspot.tw/2018/02/botframework-botbuilder-linebot_10.html

Code Sample

  • example express - https://github.com/Wolke/botbuilder-linebot-connector-example
  • example serverless - https://github.com/Wolke/linebot-serverless-MongoDbStorage-LineConnector-typeScript-starter-Kit

javaScript

var builder = require("botbuilder")
var LineConnector = require("botbuilder-linebot-connector");

var express = require('express');
var server = express();

server.listen(process.env.port || process.env.PORT || 3980, function () {
    console.log("listening to");
});


var connector = new LineConnector.LineConnector({
    hasPushApi: false, //you have to pay for push api >.,<
    autoGetUserProfile:true, //default is false
    // your line
    channelId: process.env.channelId || "",
    channelSecret: process.env.channelSecret || "",
    channelAccessToken: process.env.channelAccessToken || ""
});

server.post('/line', connector.listen());

var bot = new builder.UniversalBot(connector)

var push = new builder.Message()
    .address(<any>a)
    .addAttachment(new ImageMap(<any>a,
        "test",
        "https://www.profolio.com/sites/default/files/styles/1920x1040/public/field/image/Bikini_Girls_adx.jpg?itok=uciEvomy",
        {
            "width": 1040,
            "height": 1040
        },
        []
    ))
bot.send(push);

bot.dialog("/", s => {
            try{
                let u = await connector.getUserProfile(s.message.from.id)
                console.log("u" + u)
                if (u === undefined) {
                    s.send("who said:" + s.message.text)
                } else {
                    s.send("hello " + u.displayName)
                }
            }catch(e){
                s.send("can`t get user profile!")
            }
            //image map
            
        s.send(new builder.Message(s).addAttachment(new ImageMap(s,
            "test",
            "https://www.profolio.com/sites/default/files/styles/1920x1040/public/field/image/Bikini_Girls_adx.jpg?itok=uciEvomy",
            {
                "width": 1040,
                "height": 1040
            },
            [
                {
                    "type": "uri",
                    "linkUri": "https://google.com/",
                    "area": {
                        "x": 0,
                        "y": 0,
                        "width": 333,
                        "height": 1040
                    }
                },
                {
                    "type": "message",
                    "label": "good",
                    "text": "hot",
                    "area": {
                        "x": 333,
                        "y": 0,
                        "width": 333,
                        "height": 1040
                    }
                },
            ]


        )));

    s.send(new builder.Message(s)
        /* Sticker  */
        .addAttachment(
            new LineConnector.Sticker(s, 1, 1)
        )
        /* Location  */
        .addAttachment(
            new LineConnector.Location(s, "my test", "中和", 35.65910807942215, 139.70372892916203)
        )
        /* Audio file */
        .addAttachment(
            new builder.AudioCard(s).media([{
                url: "https://xxx", //file place must be https
                profile: "music"
            }])
            /* Image file */
        ).addAttachment(
            new builder.MediaCard(s).image(builder.CardImage.create(s, 'https://imagelab.nownews.com/?w=1080&q=85&src=http://s.nownews.com/5d/6b/5d6b74b674e643f522ed68ef83053a1f.JPG'))
            /* Video file */
        ).addAttachment(
            new builder.MediaCard(s).media('https://imagelab.nownews.com/?w=1080&q=85&src=http://s.nownews.com/5d/6b/5d6b74b674e643f522ed68ef83053a1f.JPG').image(builder.CardImage.create(s, 'https://imagelab.nownews.com/?w=1080&q=85&src=http://s.nownews.com/5d/6b/5d6b74b674e643f522ed68ef83053a1f.JPG'))
        )
    );


    /* Dialog */
    s.send(new builder.Message(s)
        .addAttachment(
            new builder.HeroCard(s)

            .title("Classic White T-Shirt")
            .subtitle("100% Soft and Luxurious Cotton")
            .text("Price is $25 and carried in sizes (S, M, L, and XL)")
            .images([builder.CardImage.create(s, 'https://imagelab.nownews.com/?w=1080&q=85&src=http://s.nownews.com/11/b9/11b93df1ec7012f4d772c8bb0ac74e10.png')])

            .buttons([
                //left text message
                builder.CardAction.imBack(s, "buy classic gray t-shirt", "Buy"),
                //set timer
                new builder.CardAction().type("datatimepicker").title("time"),
                //postback
                builder.CardAction.postBack(s, "action=buy&itemid=111", "send data"),
                //open irl
                builder.CardAction.openUrl(s, "https://1797.tw", "1797")

            ])
        )
    )
        /* Carosuel */
          
        var msg = new builder.Message(s);
        msg.attachmentLayout(builder.AttachmentLayout.carousel)
        msg.attachments([

            new builder.HeroCard(s)
                .title("Classic White T-Shirt")
                .subtitle("100% Soft and Luxurious Cotton")
                .text("Price is $25 and carried in sizes (S, M, L, and XL)")
                .images([builder.CardImage.create(s, 'https://imagelab.nownews.com/?w=1080&q=85&src=http://s.nownews.com/11/b9/11b93df1ec7012f4d772c8bb0ac74e10.png')])
                .buttons([
                    builder.CardAction.openUrl(s, "https://1797.tw", "1797"),
                    new builder.CardAction().type("datatimepicker").title("time"),
                    builder.CardAction.postBack(s, "action=buy&itemid=111", "send data"),
                ]),
            new builder.HeroCard(s)
                .title("Classic Gray T-Shirt")
                .subtitle("100% Soft and Luxurious Cotton")
                .text("Price is $25 and carried in sizes (S, M, L, and XL)")
                .images([builder.CardImage.create(s, 'https://imagelab.nownews.com/?w=1080&q=85&src=http://s.nownews.com/5d/6b/5d6b74b674e643f522ed68ef83053a1f.JPG')])
                .buttons([
                    new builder.CardAction().type("datatimepicker").title("time"),
                    builder.CardAction.imBack(s, "buy classic gray t-shirt", "Buy"),
                    builder.CardAction.postBack(s, "action=buy&itemid=111", "send data"),
                ])
        ]);
        s.send(msg)


})


bot.dialog('leave'
    , s => {
        s.send("byebye");
        //only work in group or room
        connector.leave();

        s.endDialog()

    }
).triggerAction({
    matches: /^leave$/i
});

bot.on('conversationUpdate', function (message) {
    // detect event
    switch (message.text) {
        case 'follow':
            break;
        case 'unfollow':
            break;
        case 'join':
            break;
        case 'leave':
            break;
    }
    var isGroup = message.address.conversation.isGroup;
    var txt = isGroup ? "Hello everyone!" : "Hello " + message.from.name;
    var reply = new builder.Message()
        .address(message.address)
        .text(txt);
    bot.send(reply);
    bot.beginDialog(message.address, "hello")
});

bot.dialog("hello", [
    s => {
        builder.Prompts.text(s, "go");
    },
    (s, r) => {
        s.send("oh!" + r.response)
        s.endDialog()
    }
])

License

The MIT license

#If you like this, Welcome to give me Star