Bot

Flex message 전송 관련 문의

Daeyeon Jung(_fcf268

2023.11.23既読 372

投稿内容は一般公開されて誰でも確認できます。

계정 이름, 도메인 이름, 클라이언트 ID, 클라이언트 비밀번호 등 비공개 정보를 잘못 입력하지 않도록주의하십시오.

​​

안녕하세요? bot에 메시지를 전송하려고합니다. 아래와 같은 Flex message를 작성했습니다.

관련해서 문제점에 대한 조언 부탁드립니다.


final flexMsg = {
"content" : {
"type" : "flex" ,
"altText" : "this is a flexible template" ,
"contents" : {
"type" : "bubble" ,
"styles" : {
"footer" : { "separator" : true }
},
"body" : {
"type" : "box" ,
"layout" : "vertical" ,
"contents" : [
{ "type" : "text" , "text" : "Monitoring Report" , "weight" : "bold" , "color" : "#1DB446" , "size" : "sm" },
{
"type" : "text" ,
"text" : "VIRIYA Summary" ,
"weight" : "bold" ,
"size" : "xl" ,
"margin" : "md" ,
"color" : "#222222"
},
{ "type" : "text" , "text" : "https://viriya.mogoscorp.com" , "size" : "xxs" , "color" : "#aaaaaa" , "wrap" : true },
{ "type" : "separator" , "margin" : "xxl" },
{
"type" : "box" ,
"layout" : "horizontal" ,
"contents" : [
{
"type" : "box" ,
"layout" : "vertical" ,
"contents" : [
{ "type" : "text" , "text" : "Name" , "size" : "xs" , "weight" : "regular" , "color" : "#222222" }
]
},
{
"layout" : "vertical" ,
"action" : { "type" : "" },
"type" : "box" ,
"contents" : [
{
"text" : "Success" ,
"action" : { "type" : "" },
"type" : "text" ,
"size" : "xs"
}
]
},
{
"type" : "box" ,
"layout" : "vertical" ,
"contents" : [
{
"type" : "text" ,
"text" : "Failure" ,
"size" : "xs" ,
"align" : "end" ,
"weight" : "regular" ,
"color" : "#FF0000"
}
],
"width" : "40px" ,
"margin" : "sm"
},
{
"layout" : "vertical" ,
"action" : { "type" : "" },
"type" : "box" ,
"contents" : [
{
"text" : "ms" ,
"action" : { "type" : "" },
"type" : "text" ,
"size" : "xs" ,
"align" : "end"
}
],
"margin" : "sm" ,
"width" : "40px"
}
],
"margin" : "md"
},
{ "type" : "separator" , "margin" : "md" },
{
"type" : "box" ,
"layout" : "horizontal" ,
"contents" : [
{
"type" : "box" ,
"layout" : "vertical" ,
"contents" : [
{
"type" : "box" ,
"layout" : "horizontal" ,
"contents" : [
{
"type" : "box" ,
"layout" : "vertical" ,
"contents" : [],
"width" : "2px" ,
"backgroundColor" : "#222222" ,
"height" : "20px" ,
"position" : "absolute" ,
"margin" : "xs"
},
{
"type" : "text" ,
"size" : "xs" ,
"color" : "#999999" ,
"flex" : 0 ,
"margin" : "xs" ,
"offsetStart" : "10px" ,
"text" : "MemberList"
}
]
}
],
"margin" : "xs"
},
{
"layout" : "vertical" ,
"action" : { "type" : "" },
"type" : "box" ,
"contents" : [
{
"text" : "30" ,
"action" : { "type" : "" },
"type" : "text" ,
"size" : "xxs" ,
"align" : "center"
}
]
},
{
"type" : "box" ,
"layout" : "vertical" ,
"contents" : [
{ "type" : "text" , "text" : "0" , "size" : "xs" , "align" : "center" , "color" : "#FF0000" }
],
"margin" : "sm" ,
"width" : "40px"
},
{
"layout" : "vertical" ,
"action" : { "type" : "" },
"type" : "box" ,
"contents" : [
{
"text" : "980" ,
"action" : { "type" : "" },
"type" : "text" ,
"size" : "xxs" ,
"align" : "end"
}
],
"width" : "40px" ,
"margin" : "sm"
}
],
"margin" : "sm"
},
{
"type" : "box" ,
"layout" : "horizontal" ,
"contents" : [
{
"type" : "box" ,
"layout" : "vertical" ,
"contents" : [
{
"type" : "box" ,
"layout" : "horizontal" ,
"contents" : [
{
"type" : "box" ,
"layout" : "vertical" ,
"contents" : [],
"width" : "2px" ,
"backgroundColor" : "#222222" ,
"height" : "20px" ,
"position" : "absolute"
},
{
"type" : "text" ,
"size" : "xs" ,
"color" : "#999999" ,
"flex" : 0 ,
"margin" : "xs" ,
"offsetStart" : "10px" ,
"text" : "LocationList"
}
]
}
],
"margin" : "xs"
},
{
"layout" : "vertical" ,
"action" : { "type" : "" },
"type" : "box" ,
"contents" : [
{
"text" : "30" ,
"action" : { "type" : "" },
"type" : "text" ,
"size" : "xxs" ,
"align" : "center"
}
]
},
{
"type" : "box" ,
"layout" : "vertical" ,
"contents" : [
{
"type" : "text" ,
"color" : "#FF0000" ,
"size" : "xs" ,
"text" : "0" ,
"align" : "center" ,
"offsetTop" : "2px"
}
],
"width" : "40px" ,
"margin" : "sm"
},
{
"type" : "box" ,
"layout" : "vertical" ,
"contents" : [
{ "type" : "text" , "text" : "500" , "color" : "#999999" , "size" : "xxs" , "align" : "end" }
],
"margin" : "sm" ,
"width" : "40px"
}
]
},
{ "type" : "separator" , "margin" : "xl" },
{
"type" : "box" ,
"layout" : "horizontal" ,
"margin" : "md" ,
"contents" : [
{ "type" : "text" , "text" : "ISSUE DATE" , "size" : "xs" , "color" : "#aaaaaa" , "flex" : 0 },
{ "type" : "text" , "text" : "2020-12-05" , "color" : "#aaaaaa" , "size" : "xs" , "align" : "end" }
]
}
]
},
"footer" : { "separator" : true }
}
}
};

request.body = json. encode (flexMsg);

コメント1

  • 업데이트 된 답글입니다.

    Flexメッセージを作成する際には、以下の点に注意してください。

    JSON構造の正確さ: FlexメッセージはJSON形式で定義されます。JSONの構造が正しくないと、メッセージは送信されません。JSONの構文エラー、不足しているカンマや括弧などの細かいミスに注意してください。

    デザインの制約: Flexメッセージは非常に柔軟ですが、LINE WORKSのガイドラインに従ったデザインである必要があります。例えば、コンテナのサイズ、マージン、パディングなどのプロパティがあります。これらの制約を守らないと、メッセージが意図した通りに表示されない可能性があります。

    プレビューの利用: Flexメッセージのデザインを確認するためには、LINE WORKSの提供するプレビューツールを使用すると良いでしょう。これにより、実際に送信する前にメッセージの見た目を確認できます。

    アクションの設定: ボタンやイメージなど、ユーザーがインタラクションできる要素にはアクションを設定する必要があります。ポストバックアクション、メッセージアクション、URIアクションなど、適切なアクションを設定してください。

    サイズ制限: Flexメッセージにはサイズ制限があります。メッセージのサイズが大きすぎると、送信できないので注意してください。

    テスト: 実際にデバイスでテストを行い、異なるデバイスや画面サイズでの表示を確認してください。デザインが崩れないか、アクションが正しく機能するかなどをチェックします。

    ドキュメントの確認: LINE WORKSのAPIドキュメントは定期的に更新されることがあります。最新の情報を確認し、変更点がないかをチェックしてください。

    Flexメッセージの作成には細心の注意が必要です。上記のポイントを確認し、問題がないかを慎重にチェックしてください。もし不明点があれば、LINE WORKSのドキュメントを参照するか、具体的なコード例を提供していただければ、さらに詳しいアドバイスをすることができます。

    2023.12.29

    0
前の投稿 自動でトークルームのノートにコメントを追加したいです。
次の投稿APIの制限について
リスト

まだ、解決できませんか?
今すぐ実際に使用しているLINE WORKSユーザーに質問してみましょう。