docs: README, COMMUNITY_POST und BUTTON_GUIDE für v2.0 aktualisiert
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
# Button Guide — Hermes Rocket.Chat Plugin
|
||||
|
||||
## How to Send Buttons
|
||||
|
||||
The agent uses `send_message` with a `metadata` dict. The adapter converts this to native Rocket.Chat attachments.
|
||||
|
||||
### Built-in Templates
|
||||
|
||||
| Template | Buttons | Label Length |
|
||||
|----------|---------|-------------|
|
||||
| `yes_no` | ✅Ja / ❌Nein | 4-5 chars |
|
||||
| `confirm_cancel` | ✅Bestätigen / 🚫Abbrechen | 11-12 chars* |
|
||||
| `ok` | 👍OK | 3 chars |
|
||||
| `multi_choice_3` | 1. Links / 2. Rechts / 3. Zwei Runden | 8-13 chars |
|
||||
|
||||
*Desktop truncation at ~7 chars — `Bestätigen` shows as `Bestäti…` but full value transmitted on click.
|
||||
|
||||
### Custom Buttons
|
||||
|
||||
```python
|
||||
send_message(
|
||||
target="rocketchat:protonbridge",
|
||||
text="Should I proceed?",
|
||||
metadata={
|
||||
"template": "custom",
|
||||
"question_id": "confirm_42",
|
||||
"button_title": "Choice:",
|
||||
"custom_buttons": ["✅Ja", "❌Nein", "🟡Später"]
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
## How to Receive Button Clicks
|
||||
|
||||
Button clicks arrive as plain text:
|
||||
|
||||
```
|
||||
confirm_42::✅Ja
|
||||
```
|
||||
|
||||
The `question_id` is the prefix, the chosen label follows after `::`.
|
||||
|
||||
## Button Label Rules
|
||||
|
||||
### Critical Rules
|
||||
|
||||
1. **NO underscores (`_`)** — destroys button rendering completely (grey container, no buttons)
|
||||
2. **Desktop truncation at ~7 chars** — first 7 characters must be distinguishable across all buttons in a group
|
||||
3. **Mobile shows full text** — but design for desktop-first
|
||||
4. **Spaces ARE allowed** — `1. Links` works; `1._Links` breaks
|
||||
|
||||
### Platform Behavior
|
||||
|
||||
| Platform | Behavior |
|
||||
|----------|----------|
|
||||
| Desktop App | Truncates at ~5-7 chars → `1234567…` |
|
||||
| Mobile App | Full text visible |
|
||||
| Clipboard | Always full text |
|
||||
|
||||
### Best Practice: Numbered References
|
||||
|
||||
Put full descriptions in the message body, use short numbered references as button labels:
|
||||
|
||||
```python
|
||||
text = (
|
||||
"**Options:**\n"
|
||||
"1. Copy program code to the left\n"
|
||||
"2. Fly around the program code\n"
|
||||
"3. Spin twice around own axis"
|
||||
)
|
||||
buttons = ["1. Links", "2. Rechts", "3. Zwei Runden"]
|
||||
```
|
||||
|
||||
### Emoji+Text Pattern (Preferred by Operator)
|
||||
|
||||
```python
|
||||
buttons = ["✅Ja", "❌Nein", "🟡Später"]
|
||||
```
|
||||
|
||||
Short, distinguishable, visually distinct.
|
||||
|
||||
## Why `question_id` Is Mandatory
|
||||
|
||||
Without it, a late click on an old button creates silent context errors. Always assign descriptive, domain-prefixed IDs:
|
||||
|
||||
- `confirm_42`, `export_format_001`, `direction_left_right`
|
||||
|
||||
## Full Multi-Step Example
|
||||
|
||||
```python
|
||||
# Step 1: Choose format
|
||||
send_message(
|
||||
target="rocketchat:protonbridge",
|
||||
text="Which export format?",
|
||||
metadata={
|
||||
"template": "custom",
|
||||
"button_title": "Format:",
|
||||
"question_id": "export_format_001",
|
||||
"custom_buttons": ["CSV", "JSON", "Excel"]
|
||||
}
|
||||
)
|
||||
# User clicks → "export_format_001::CSV"
|
||||
|
||||
# Step 2: Choose destination
|
||||
send_message(
|
||||
target="rocketchat:protonbridge",
|
||||
text="Where to send the CSV?",
|
||||
metadata={
|
||||
"template": "custom",
|
||||
"button_title": "Destination:",
|
||||
"question_id": "export_dest_001",
|
||||
"custom_buttons": ["📧Mail", "💾Download", "☁️Cloud"]
|
||||
}
|
||||
)
|
||||
# User clicks → "export_dest_001::💾Download"
|
||||
```
|
||||
Reference in New Issue
Block a user