Skip to content

message type example

찰스 edited this page Jul 26, 2023 · 1 revision
  • example
// Text message example
{
    "type": "text",
    "text": "Hello, world"
}

// Text message example with LINE emoji
{
    "type": "text",
    "text": "$ LINE emoji $",
    "emojis": [
      {
        "index": 0,
        "productId": "5ac1bfd5040ab15980c9b435",
        "emojiId": "001"
      },
      {
        "index": 13,
        "productId": "5ac1bfd5040ab15980c9b435",
        "emojiId": "002"
      }
    ]
}
  • implement
// Text message example
IMessage message1 = new TextMessage()
{
    Text = "Hello, World",
};

// Text message example with LINE emoji
IMessage message2 = new TextMessage()
{
    Text = "$ LINE emoji $",
    Emojis = new List<Emoji>()
    { 
        new Emoji()
        { 
            Index = 0,
            ProductId = "5ac1bfd5040ab15980c9b435",
            EmojiId = "001"
        },
        new Emoji()
        {
            Index = 13,
            ProductId = "5ac1bfd5040ab15980c9b435",
            EmojiId = "002"
        }
    }
};
  • example
{
  "type": "sticker",
  "packageId": "446",
  "stickerId": "1988"
}
  • implement
IMessage message = new StickerMessage()
{
    PackageId = "446",
    StickerId = "1988"
};
  • example
{
  "type": "image",
  "originalContentUrl": "https://example.com/original.jpg",
  "previewImageUrl": "https://example.com/preview.jpg"
}
  • implement
IMessage message = new ImageMessage()
{
    OriginalContentUrl = "https://example.com/original.jpg",
    PreviewImageUrl = "https://example.com/preview.jpg"
};
  • example
{
  "type": "video",
  "originalContentUrl": "https://example.com/original.mp4",
  "previewImageUrl": "https://example.com/preview.jpg",
  "trackingId": "track-id"
}
  • implement
IMessage message = new VideoMessage()
{
    OriginalContentUrl = "https://example.com/original.mp4",
    PreviewImageUrl = "https://example.com/preview.jpg",
    TrackingId = "track-id"
};
  • example
{
  "type": "audio",
  "originalContentUrl": "https://example.com/original.m4a",
  "duration": 60000
}
  • implement
IMessage message = new AudioMessage()
{
    OriginalContentUrl = "https://example.com/original.m4a",
    Duration = 60000
};
  • example
{
  "type": "location",
  "title": "my location",
  "address": "1-6-1 Yotsuya, Shinjuku-ku, Tokyo, 160-0004, Japan",
  "latitude": 35.687574,
  "longitude": 139.72922
}
  • implement
IMessage message = new LocationMessage()
{
    Title = "my location",
    Address = "1-6-1 Yotsuya, Shinjuku-ku, Tokyo, 160-0004, Japan",
    Latitude = 35.687574m,
    Longitude = 139.72922m
};
  • example
{
  "type": "imagemap",
  "baseUrl": "https://example.com/bot/images/rm001",
  "altText": "This is an imagemap",
  "baseSize": {
    "width": 1040,
    "height": 1040
  },
  "video": {
    "originalContentUrl": "https://example.com/video.mp4",
    "previewImageUrl": "https://example.com/video_preview.jpg",
    "area": {
      "x": 0,
      "y": 0,
      "width": 1040,
      "height": 585
    },
    "externalLink": {
      "linkUri": "https://example.com/see_more.html",
      "label": "See More"
    }
  },
  "actions": [
    {
      "type": "uri",
      "linkUri": "https://example.com/",
      "area": {
        "x": 0,
        "y": 586,
        "width": 520,
        "height": 454
      }
    },
    {
      "type": "message",
      "text": "Hello",
      "area": {
        "x": 520,
        "y": 586,
        "width": 520,
        "height": 454
      }
    }
  ]
}
  • implement
IMessage message = new ImageMapMessage()
{
    BaseUrl = "https://example.com/bot/images/rm001",
    AltText = "This is an imagemap",
    BaseSize = new ImageMapBaseSize()
    { 
        Width = 1040,
        Height = 1040
    },
    Video = new ImageMapVideo()
    { 
        OriginalContentUrl = "https://example.com/video.mp4",
        PreviewImageUrl = "https://example.com/video_preview.jpg",
        Area = new ImageMapVideoArea()
        { 
            X = 0,
            Y = 0,
            Width = 1040,
            Height = 585
        },
        ExternalLink = new ImageMapExternalLink()
        { 
            LinkUri = "https://example.com/see_more.html",
            Label = "See More"
        }
    },
    Actions = new List<IImageMapAction>()
    { 
        new ImageMapUriAction()
        { 
            LinkUri = "https://example.com/",
            Area = new ImageMapArea()
            { 
                X = 0,
                Y = 586,
                Width = 520,
                Height = 454
            }
        },
        new ImageMapMessageAction()
        {
            Text = "Hello",
            Area = new ImageMapArea()
            {
                X = 0,
                Y = 586,
                Width = 520,
                Height = 454
            }
        }    
    }
};
  • example
{
  "type": "template",
  "altText": "This is a buttons template",
  "template": {
    "type": "buttons",
    "thumbnailImageUrl": "https://example.com/bot/images/image.jpg",
    "imageAspectRatio": "rectangle",
    "imageSize": "cover",
    "imageBackgroundColor": "#FFFFFF",
    "title": "Menu",
    "text": "Please select",
    "defaultAction": {
      "type": "uri",
      "label": "View detail",
      "uri": "http://example.com/page/123"
    },
    "actions": [
      {
        "type": "postback",
        "label": "Buy",
        "data": "action=buy&itemid=123"
      },
      {
        "type": "postback",
        "label": "Add to cart",
        "data": "action=add&itemid=123"
      },
      {
        "type": "uri",
        "label": "View detail",
        "uri": "http://example.com/page/123"
      }
    ]
  }
}
  • implement
IMessage message = new TemplateMessage()
{
    AltText = "This is a buttons template",
    Template = new ButtonTemplate()
    { 
        ThumbnailImageUrl = "https://example.com/bot/images/image.jpg",
        ImageAspectRatio = "rectangle",
        ImageSize = "cover",
        ImageBackgroundColor = "#FFFFFF",
        Title = "Menu",
        Text = "Please select",
        DefaultAction = new UriAction()
        { 
            Label = "View detail",
            Uri = "http://example.com/page/123"
        },
        Actions = new List<IAction>()
        { 
            new PostBackAction()
            { 
                Label = "Buy",
                Data = "action=buy&itemid=123"
            },
            new PostBackAction()
            {
                Label = "Add to cart",
                Data = "action=add&itemid=123"
            },
            new UriAction()
            {
              Label = "View detail",
              Uri = "http://example.com/page/123"
            }
        }
    }
};
  • example
{
  "type": "template",
  "altText": "this is a confirm template",
  "template": {
    "type": "confirm",
    "text": "Are you sure?",
    "actions": [
      {
        "type": "message",
        "label": "Yes",
        "text": "yes"
      },
      {
        "type": "message",
        "label": "No",
        "text": "no"
      }
    ]
  }
}
  • implement
IMessage message = new TemplateMessage()
{
    AltText = "this is a confirm template",
    Template = new ConfirmTemplate()
    { 
        Text = "Are you sure?",
        Actions = new List<IAction>()
        {
            new MessageAction()
            {
                Label = "Yes",
                Text = "yes"
            },
            new MessageAction()
            { 
                Label = "No",
                Text = "no"
            }
        }
    }
};
  • example
{
  "type": "template",
  "altText": "this is a carousel template",
  "template": {
    "type": "carousel",
    "columns": [
      {
        "thumbnailImageUrl": "https://example.com/bot/images/item1.jpg",
        "imageBackgroundColor": "#FFFFFF",
        "title": "this is menu",
        "text": "description",
        "defaultAction": {
          "type": "uri",
          "label": "View detail",
          "uri": "http://example.com/page/123"
        },
        "actions": [
          {
            "type": "postback",
            "label": "Buy",
            "data": "action=buy&itemid=111"
          },
          {
            "type": "postback",
            "label": "Add to cart",
            "data": "action=add&itemid=111"
          },
          {
            "type": "uri",
            "label": "View detail",
            "uri": "http://example.com/page/111"
          }
        ]
      },
      {
        "thumbnailImageUrl": "https://example.com/bot/images/item2.jpg",
        "imageBackgroundColor": "#000000",
        "title": "this is menu",
        "text": "description",
        "defaultAction": {
          "type": "uri",
          "label": "View detail",
          "uri": "http://example.com/page/222"
        },
        "actions": [
          {
            "type": "postback",
            "label": "Buy",
            "data": "action=buy&itemid=222"
          },
          {
            "type": "postback",
            "label": "Add to cart",
            "data": "action=add&itemid=222"
          },
          {
            "type": "uri",
            "label": "View detail",
            "uri": "http://example.com/page/222"
          }
        ]
      }
    ],
    "imageAspectRatio": "rectangle",
    "imageSize": "cover"
  }
}
  • implement
IMessage message = new TemplateMessage()
{
    AltText = "this is a carousel template",
    Template = new CarouselTemplate()
    { 
        Columns = new List<CarouselColumnObject>()
        { 
            new CarouselColumnObject()
            {
                ThumbnailImageUrl = "https://example.com/bot/images/item1.jpg",
                ImageBackgroundColor =  "#FFFFFF",
                Title = "this is menu",
                Text = "description",
                DefaultAction = new UriAction()
                { 
                    Label = "View detail",
                    Uri = "http://example.com/page/123"
                },
                Actions = new List<IAction>()
                { 
                    new PostBackAction()
                    { 
                        Label = "Buy",
                        Data = "action=buy&itemid=111"
                    },
                    new PostBackAction()
                    {
                        Label = "Add to cart",
                        Data = "action=add&itemid=111"
                    },
                    new UriAction()
                    {
                        Label = "View detail",
                        Uri = "http://example.com/page/111"
                    }
                }
            },
            new CarouselColumnObject()
            {
                ThumbnailImageUrl = "https://example.com/bot/images/item2.jpg",
                ImageBackgroundColor = "#000000",
                Title = "this is menu",
                Text = "description",
                DefaultAction = new UriAction()
                {
                    Label = "View detail",
                    Uri = "http://example.com/page/222"
                },
                Actions = new List<IAction>()
                {
                    new PostBackAction()
                    {
                        Label = "Buy",
                        Data = "action=buy&itemid=222"
                    },
                    new PostBackAction()
                    {
                        Label = "Add to cart",
                        Data = "action=add&itemid=222"
                    },
                    new UriAction()
                    {
                        Label = "View detail",
                        Uri = "http://example.com/page/222"
                    }
                }
            }
        },
        ImageAspectRatio = "rectangle",
        ImageSize = "cover"
    }
};
  • example
{
  "type": "template",
  "altText": "this is a image carousel template",
  "template": {
    "type": "image_carousel",
    "columns": [
      {
        "imageUrl": "https://example.com/bot/images/item1.jpg",
        "action": {
          "type": "postback",
          "label": "Buy",
          "data": "action=buy&itemid=111"
        }
      },
      {
        "imageUrl": "https://example.com/bot/images/item2.jpg",
        "action": {
          "type": "message",
          "label": "Yes",
          "text": "yes"
        }
      },
      {
        "imageUrl": "https://example.com/bot/images/item3.jpg",
        "action": {
          "type": "uri",
          "label": "View detail",
          "uri": "http://example.com/page/222"
        }
      }
    ]
  }
}
  • implement
IMessage message = new TemplateMessage()
{
    AltText = "this is a image carousel template",
    Template = new ImageCarouselTemplate()
    { 
        Columns = new List<ImageCarouselColumnObject>()
        {
            new ImageCarouselColumnObject()
            { 
                ImageUrl = "https://example.com/bot/images/item1.jpg",
                Action = new PostBackAction()
                { 
                    Label = "Buy",
                    Data = "action=buy&itemid=111"
                }
            },
            new ImageCarouselColumnObject()
            {
                ImageUrl = "https://example.com/bot/images/item2.jpg",
                Action = new MessageAction()
                {
                    Label = "Yes",
                    Text = "yes"
                }
            },
            new ImageCarouselColumnObject()
            {
                ImageUrl = "https://example.com/bot/images/item3.jpg",
                Action = new UriAction()
                {
                    Label = "View detail",
                    Uri = "http://example.com/page/222"
                }
            }
        }
    }
};