LineBotKit.Client 1.0.7

LINE Messaging API for .NET

There is a newer version of this package available.
See the version list below for details.
Install-Package LineBotKit.Client -Version 1.0.7
dotnet add package LineBotKit.Client --version 1.0.7
<PackageReference Include="LineBotKit.Client" Version="1.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LineBotKit.Client --version 1.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

LineBotKit

GitHub license
Build status
NuGet
NuGet

Summary :

Provide functions which integrate with Line Messaging api

Pre-prepare

Developer need to apply line api token first , you can reference the following link :

Where apply the token :https://at.line.me
How to apply and setup instruction : https://dotblogs.com.tw/rexhuang/2017/07/02/120455
Installation

Install-Package LineBotKit.Client -Version 1.0.0

How to initial line bot :

The token string come from we setup above

   ILineClientManager clientManager = new LineClientManager("token");
Easy sample for send text message :

The token string come from we setup above

   ILineClientManager clientManager = new LineClientManager("token");
   clientManager.PushTextMessage("user id","message");
Provide interface to implement IoC like following
  container.RegisterType<ILineClientManager, LineClientManager>(
                  new InjectionConstructor("token"));
What functionalities do we have
//Send message related functions:
Task<ResponseItem> PushTextMessage(string to , string message);
Task<ResponseItem> PushImageMessage(string to, string imageContentUrl, string imagePreviewUrl);
Task<ResponseItem> PushStickerMessage(string to, int packageId, int stickerId);
Task<ResponseItem> PushAudioMessage(string to, string originalContentUrl, int duration);
Task<ResponseItem> PushVideoMessage(string to, string originalContentUrl, string previewImageUrl);
Task<ResponseItem> PushLocationMessage(string to, string title, string address , decimal latitude , decimal longitude);
Task<ResponseItem> PushMessage(PushMessageRequest pushMessageRequest);
Task<ResponseItem> MulticastMessage(List<string> to, List<Message> messages);

//Reply message related functions:
Task<ResponseItem> ReplyTextMessage(string to, string message);
Task<ResponseItem> ReplyImageMessage(string to, string imageContentUrl, string imagePreviewUrl);
Task<ResponseItem> ReplyStickerMessage(string to, int packageId, int stickerId);
Task<ResponseItem> ReplyMessage(ReplyMessageRequest reply);

//Room related functions:
Task<Profile> GetRoomMemberProfile(string userId, string groupId);
Task<MemberIdensResponse> GetRoomMemberIds(string roomId);

//Group related functions:
Task<ResponseItem> LeaveGroup(string groupId);
Task<Profile> GetGroupMemberProfile(string userId, string groupId);
Task<MemberIdensResponse> GetGroupMemberIds(string groupId);

//Profile related functions:
Task<Profile> GetProfile(string userId);

//Rich menu related functions:
Task<RichMenu> GetRichMenu(string richMenuId);
Task<RichMenuIdResponse> CreateRichMenu(RichMenu richMenu);
Task<ResponseItem> DeleteRichMenu(string richMenuId);
Task<RichMenuIdResponse> GetRichMenuByUserId(string userId);
Task<ResponseItem> LinkRichMenuWithUser(string userId, string richMenuId);
Task<ResponseItem> UnLinkRichMenuWithUser(string userId);
Task<RichMenuListResponse> GetRichMenuList();
Task<ResponseItem> SetRichMenuImage(string richMenuId , byte[] image);
Stream GetRichMenuImage(string richMenuId);

//Others : 
Stream GetMessageContent(string messageId);

Examples :

//multiple message with different message type

var response = await lineManager.PushMessage(
new PushMessageRequest()
{
  to = "User Iden",
  messages = new List<Message>() {
             new TextMessage("Test first message"),
             new ImageMessage("Orginally Content Url","Preview Image Url")
  }

});
            

//buttons template message

 ResponseItem response = await lineManager.PushMessage(
 new PushMessageRequest()
 {
   to = "User Iden",
   messages = new List<Message>() {
              new TemplateMessage(){
                  altText = "altText",
                  template = new ButtonsTemplate(){
                  text = "text",
                  thumbnailImageUrl = "Thumbnail Image Url",
                  title = "title",
                  actions = new List<TemplateAction>(){
                            new UriAction(){
                                label = "test",
                                uri = "http://www.yahoo.com.tw"
                            }
                  }
              }
              }
  }
});

// Confirm template message

ResponseItem response = await lineManager.PushMessage(
new PushMessageRequest()
{
    to = "User Iden",
    messages = new List<Message>() {
            new TemplateMessage(){
                altText = "altText",
                template = new ConfirmTemplate(){
                    text = "text",
                    actions = new List<TemplateAction>(){
                        new MessageAction(){
                            label = "test",
                            text = "text"
                        },
                            new MessageAction(){
                            label = "test",
                            text = "text"
                        }
                    }
                }
            }
    }
});

//Carousel template message

 ResponseItem response = await lineManager.PushMessage(
 new PushMessageRequest()
 {
     to = "User Iden",
     messages = new List<Message>() {
          new TemplateMessage(){
               altText = "altText",
               template = new CarouselTemplate(){
                    columns = new List<TemplateColumn>(){
                         new TemplateColumn(){
                              title = "title",
                              text = "text",
                              ThumbnailImageUrl = "Thumbnail image url",
                              actions = new  List<TemplateAction>(){
                                     new MessageAction(){
                                          label = "label",
                                          text = "text"
                                     }
                              }
                         }
                    }
               }
          }
     }
 });


Quick glimpse what the result looks like

1. Open the application which under "Simulator"  file
2. Excute the application and change the url with like "http://localhost:port/swagger"
3. You will see the following page

![2018-03-08_225107](https://user-images.githubusercontent.com/4464354/37158499-7baf8904-2326-11e8-9970-310c0f0c9a44.jpg)

LineBotKit

GitHub license
Build status
NuGet
NuGet

Summary :

Provide functions which integrate with Line Messaging api

Pre-prepare

Developer need to apply line api token first , you can reference the following link :

Where apply the token :https://at.line.me
How to apply and setup instruction : https://dotblogs.com.tw/rexhuang/2017/07/02/120455
Installation

Install-Package LineBotKit.Client -Version 1.0.0

How to initial line bot :

The token string come from we setup above

   ILineClientManager clientManager = new LineClientManager("token");
Easy sample for send text message :

The token string come from we setup above

   ILineClientManager clientManager = new LineClientManager("token");
   clientManager.PushTextMessage("user id","message");
Provide interface to implement IoC like following
  container.RegisterType<ILineClientManager, LineClientManager>(
                  new InjectionConstructor("token"));
What functionalities do we have
//Send message related functions:
Task<ResponseItem> PushTextMessage(string to , string message);
Task<ResponseItem> PushImageMessage(string to, string imageContentUrl, string imagePreviewUrl);
Task<ResponseItem> PushStickerMessage(string to, int packageId, int stickerId);
Task<ResponseItem> PushAudioMessage(string to, string originalContentUrl, int duration);
Task<ResponseItem> PushVideoMessage(string to, string originalContentUrl, string previewImageUrl);
Task<ResponseItem> PushLocationMessage(string to, string title, string address , decimal latitude , decimal longitude);
Task<ResponseItem> PushMessage(PushMessageRequest pushMessageRequest);
Task<ResponseItem> MulticastMessage(List<string> to, List<Message> messages);

//Reply message related functions:
Task<ResponseItem> ReplyTextMessage(string to, string message);
Task<ResponseItem> ReplyImageMessage(string to, string imageContentUrl, string imagePreviewUrl);
Task<ResponseItem> ReplyStickerMessage(string to, int packageId, int stickerId);
Task<ResponseItem> ReplyMessage(ReplyMessageRequest reply);

//Room related functions:
Task<Profile> GetRoomMemberProfile(string userId, string groupId);
Task<MemberIdensResponse> GetRoomMemberIds(string roomId);

//Group related functions:
Task<ResponseItem> LeaveGroup(string groupId);
Task<Profile> GetGroupMemberProfile(string userId, string groupId);
Task<MemberIdensResponse> GetGroupMemberIds(string groupId);

//Profile related functions:
Task<Profile> GetProfile(string userId);

//Rich menu related functions:
Task<RichMenu> GetRichMenu(string richMenuId);
Task<RichMenuIdResponse> CreateRichMenu(RichMenu richMenu);
Task<ResponseItem> DeleteRichMenu(string richMenuId);
Task<RichMenuIdResponse> GetRichMenuByUserId(string userId);
Task<ResponseItem> LinkRichMenuWithUser(string userId, string richMenuId);
Task<ResponseItem> UnLinkRichMenuWithUser(string userId);
Task<RichMenuListResponse> GetRichMenuList();
Task<ResponseItem> SetRichMenuImage(string richMenuId , byte[] image);
Stream GetRichMenuImage(string richMenuId);

//Others : 
Stream GetMessageContent(string messageId);

Examples :

//multiple message with different message type

var response = await lineManager.PushMessage(
new PushMessageRequest()
{
  to = "User Iden",
  messages = new List<Message>() {
             new TextMessage("Test first message"),
             new ImageMessage("Orginally Content Url","Preview Image Url")
  }

});
            

//buttons template message

 ResponseItem response = await lineManager.PushMessage(
 new PushMessageRequest()
 {
   to = "User Iden",
   messages = new List<Message>() {
              new TemplateMessage(){
                  altText = "altText",
                  template = new ButtonsTemplate(){
                  text = "text",
                  thumbnailImageUrl = "Thumbnail Image Url",
                  title = "title",
                  actions = new List<TemplateAction>(){
                            new UriAction(){
                                label = "test",
                                uri = "http://www.yahoo.com.tw"
                            }
                  }
              }
              }
  }
});

// Confirm template message

ResponseItem response = await lineManager.PushMessage(
new PushMessageRequest()
{
    to = "User Iden",
    messages = new List<Message>() {
            new TemplateMessage(){
                altText = "altText",
                template = new ConfirmTemplate(){
                    text = "text",
                    actions = new List<TemplateAction>(){
                        new MessageAction(){
                            label = "test",
                            text = "text"
                        },
                            new MessageAction(){
                            label = "test",
                            text = "text"
                        }
                    }
                }
            }
    }
});

//Carousel template message

 ResponseItem response = await lineManager.PushMessage(
 new PushMessageRequest()
 {
     to = "User Iden",
     messages = new List<Message>() {
          new TemplateMessage(){
               altText = "altText",
               template = new CarouselTemplate(){
                    columns = new List<TemplateColumn>(){
                         new TemplateColumn(){
                              title = "title",
                              text = "text",
                              ThumbnailImageUrl = "Thumbnail image url",
                              actions = new  List<TemplateAction>(){
                                     new MessageAction(){
                                          label = "label",
                                          text = "text"
                                     }
                              }
                         }
                    }
               }
          }
     }
 });


Quick glimpse what the result looks like

1. Open the application which under "Simulator"  file
2. Excute the application and change the url with like "http://localhost:port/swagger"
3. You will see the following page

![2018-03-08_225107](https://user-images.githubusercontent.com/4464354/37158499-7baf8904-2326-11e8-9970-310c0f0c9a44.jpg)

Release Notes

Add default actions in Buttons template and Carousel template

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
3.0.0 285 4/18/2018
2.0.0 225 4/5/2018
1.0.9 243 4/2/2018
1.0.8 452 4/1/2018
1.0.7 376 3/30/2018
1.0.6 231 3/29/2018
1.0.5 293 3/21/2018
1.0.4 314 3/17/2018
1.0.3 368 3/15/2018
1.0.2 232 3/13/2018
1.0.1 967 3/12/2018
1.0.0 250 3/4/2018