-
Notifications
You must be signed in to change notification settings - Fork 69
create rich menu operation #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@4geru |
@eucyt Hello Euchi-san. I updated to separate the tools file. However, it cannot open in my app. LINE app stands up many times, and restarts... ![]() |
Memo prompt
result{
"richMenuId": "richmenu-6ba77c74ccaf8a1153045f627cc972c3",
"setImageResponse": {},
"richMenuImagePath": "/tmp/slide-07-1749597029244.png",
"params": {
"name": "ポッチっとな",
"chatBarText": "ポッチっとな",
"selected": false,
"size": {
"width": 1600,
"height": 910
},
"areas": [
{
"bounds": {
"x": 0,
"y": 0,
"width": 1600,
"height": 900
},
"action": {
"type": "camera",
"label": "ポッチっとな"
}
}
]
}
} |
I checked image requirements. 👌 |
…ru/generate-rich-menu
"@marp-team/marp-cli": "^4.1.2", | ||
"@marp-team/marp-core": "^4.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages for generating slides/images
richmenu-templetes/templete-01.md
Outdated
section { | ||
padding: 0 !important; | ||
background-color: orange; | ||
height: 100% !important; | ||
margin-top: 0 !important; | ||
margin-bottom: 0 !important; | ||
} | ||
.columns-container { | ||
display: flex; | ||
flex-wrap: wrap; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
.column-item { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
background-color: white; | ||
box-sizing: border-box; | ||
overflow: hidden; | ||
} | ||
.column-item h3 { | ||
font-weight: bold; | ||
width: 100%; | ||
text-align: center; | ||
font-size: clamp(16px, 6vw, 50px); | ||
white-space: normal; | ||
word-break: break-all; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to put them all in a common file, but it isn't easy, so I write them by hand in each file.
}); | ||
|
||
// actions | ||
export const actionSchema = z.union([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it cannot automatically compare from line-bot-sdk-nodejs
fffcb1d
to
9c6171c
Compare
@eucyt Sorry for the wait. We have improved and verified the functionality, so please leave a review. |
b77e1cd
to
0b6bd3d
Compare
@4geru san |
Is this issue still occurring? If it is still happening, could you please provide the steps to reproduce it, specifically what is happening, and what the expected behavior should be? 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! Thank you for implementing this wonderful tool. This greatly expands the possibilities of line-bot-mcp-server.
register(server: McpServer) { | ||
server.tool( | ||
"create_rich_menu", | ||
"Create a rich menu associated with your LINE Official Account.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about clearly specifying the description to avoid that agent confuse tools to use?
"Create a rich menu associated with your LINE Official Account.", | |
"Create a rich menu based on the given actions. Generate and upload a rich menu image based on the given action. This rich menu will be registered as the default.", |
// 1. Validate the rich menu image | ||
if (templeteNo < 1 || templeteNo > 6) { | ||
return createErrorResponse("Invalid texts length"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to specify the number of elements using Zod like this? This way, the agent could know the element count constraints in advance when executing the tool.
z
.array(actionSchema)
.min(1)
.max(6)
.describe("hoge")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know this setting. thanks for comment :)
"create_rich_menu", | ||
"Create a rich menu associated with your LINE Official Account.", | ||
{ | ||
chatBarText: z.string().describe("The ID of the rich menu to create."), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this more clear?
FYI: https://developers.line.biz/en/reference/messaging-api/#rich-menu-object
chatBarText: z.string().describe("The ID of the rich menu to create."), | |
chatBarText: z.string().describe("Text displayed in the chat bar and this is also used as name of the rich menu to create"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, The ID makes us confuse :(
let setImageResponse: any = null; | ||
let setDefaultResponse: any = null; | ||
const lineActions = actions as messagingApi.Action[]; | ||
const templeteNo = lineActions.length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nits] typo
const templeteNo = lineActions.length; | |
const templateNo = lineActions.length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry!!!!
for (let index = 0; index < actions.length; index++) { | ||
const pattern = new RegExp(`<h3>item0${index + 1}</h3>`, "g"); | ||
content = content.replace(pattern, `<h3>${actions[index].label}</h3>`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Just Question] Do you have plans to be enable to fill specified original images in richmenu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I haven't planned yet. Just now, we can fill in the message.
I imagine generating the mock app from LLM, and it will update the image later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nits] templete -> template 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, if these example images are not used, I think we should remove them to avoid more maintenance.
section { | ||
padding: 0 !important; | ||
background-color: orange; | ||
height: 100% !important; | ||
margin-top: 0 !important; | ||
margin-bottom: 0 !important; | ||
} | ||
.columns-container { | ||
display: flex; | ||
flex-wrap: wrap; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
.column-item { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
background-color: white; | ||
box-sizing: border-box; | ||
overflow: hidden; | ||
} | ||
.column-item h3 { | ||
font-weight: bold; | ||
width: 100%; | ||
text-align: center; | ||
font-size: 100px; | ||
white-space: normal; | ||
word-break: break-all; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using @import url('hoge')
, can we extract common styles into a separate CSS file for reuse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was unable to run this tool with Docker on my local. I encountered the following error. Is it possible to make it compatible with Docker? (I'm also concerned about whether screenshots will work. However, if this tool could be used with Docker, it would be quite convenient 😄 )
{"error":{"errno":-2,"code":"ENOENT","syscall":"open","path":"/app/richmenu-templetes/templete-02.md"},"createRichMenuResponse":{"richMenuId":"richmenu-828cebe92610f4649aab4b0a8ea05d17"},"setImageResponse":null,"setDefaultResponse":null}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to try with Docker. I tried from dist/index.js.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add description to README.md and README.ja.md 🙏
This issue was not solved :). Some accounts are dead. 😃 However, this tool is updated. |
@4geru san Are you saying that the LINE client application in smartphone keeps crashing? In other words, is this directly unrelated to the line-bot-mcp-server or LINE Official Account? I would appreciate if you could explain the steps that lead to this malfunction. |
Hello Maintainers! 👋
Thank you for maintaining this excellent LINE Bot MCP Server project. I'm excited to contribute a new feature that adds dynamic rich menu creation capabilities. I hope this enhancement will be valuable for the community.
Background
The LINE Bot MCP Server needed functionality to create rich menus dynamically. Previously, users had to manually create rich menu images and configure them individually. There was a need for a flexible, text-based approach to generate rich menus programmatically.
Todo
1. Implemented Rich Menu Creation Feature
create_rich_menu
tool2. Built Template System
richmenu-templates/
directoryrichmenu-examples/
for reference3. Implemented Image Generation Pipeline
4. Defined LINE Bot Action Schema
src/common/schema/actionSchema.ts
with schemas for 9 action types (postback, message, uri, datetimepicker, camera, cameraRoll, location, richmenuswitch, clipboard)5. Added Dependencies
@marp-team/marp-core
: For Markdown to slide generation@marp-team/marp-cli
: Marp command-line toolsVerified
Functionality
item01 ' ~ ' item06
) in Markdown templates are properly replaced with action labelsError Handling
Technical Aspects
Result
This implementation enables automatic generation of visually appealing rich menus using only text-based configuration, significantly improving the developer experience for LINE Bot creators.
Usage
https://x.com/_4geru/status/1933793286285898071
https://x.com/_4geru/status/1933890824808632560