or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

authentication.mdindex.mdmessaging.mdrich-menus.mdrich-messages.mduser-management.mdwebhooks.md

rich-menus.mddocs/

0

# Rich Menus

1

2

Interactive menu system for LINE bot interfaces. Rich menus provide persistent navigation and quick access to bot features through customizable button layouts displayed at the bottom of the chat interface.

3

4

## Capabilities

5

6

### Rich Menu Management

7

8

Core rich menu operations including creation, retrieval, updates, and deletion.

9

10

```python { .api }

11

class MessagingApi:

12

def create_rich_menu(self, rich_menu_request: RichMenuRequest) -> RichMenuIdResponse:

13

"""

14

Create a new rich menu with custom layout and areas.

15

16

Args:

17

rich_menu_request: Rich menu configuration including size, areas, and settings

18

19

Returns:

20

RichMenuIdResponse: Created rich menu ID

21

"""

22

23

def get_rich_menu(self, rich_menu_id: str) -> RichMenuResponse:

24

"""

25

Get rich menu configuration by ID.

26

27

Args:

28

rich_menu_id: Rich menu identifier

29

30

Returns:

31

RichMenuResponse: Rich menu configuration details

32

"""

33

34

def delete_rich_menu(self, rich_menu_id: str) -> dict:

35

"""

36

Delete an existing rich menu.

37

38

Args:

39

rich_menu_id: Rich menu identifier to delete

40

41

Returns:

42

dict: Empty response on success

43

"""

44

45

def get_rich_menu_list(self) -> RichMenuListResponse:

46

"""

47

Get list of all rich menus for the bot.

48

49

Returns:

50

RichMenuListResponse: List of rich menu configurations

51

"""

52

```

53

54

### Rich Menu Images

55

56

Upload and manage rich menu background images.

57

58

```python { .api }

59

class MessagingApiBlob:

60

def set_rich_menu_image(self, rich_menu_id: str, body: bytes, content_type: str = "image/jpeg") -> dict:

61

"""

62

Upload background image for a rich menu.

63

64

Args:

65

rich_menu_id: Rich menu identifier

66

body: Image binary data

67

content_type: Image content type (image/jpeg or image/png)

68

69

Returns:

70

dict: Empty response on success

71

"""

72

73

def get_rich_menu_image(self, rich_menu_id: str) -> bytes:

74

"""

75

Download rich menu background image.

76

77

Args:

78

rich_menu_id: Rich menu identifier

79

80

Returns:

81

bytes: Image binary data

82

"""

83

```

84

85

### User Rich Menu Assignment

86

87

Link and unlink rich menus to/from specific users.

88

89

```python { .api }

90

class MessagingApi:

91

def link_rich_menu_id_to_user(self, user_id: str, rich_menu_id: str) -> dict:

92

"""

93

Link a rich menu to a specific user.

94

95

Args:

96

user_id: LINE user ID

97

rich_menu_id: Rich menu identifier to link

98

99

Returns:

100

dict: Empty response on success

101

"""

102

103

def unlink_rich_menu_id_from_user(self, user_id: str) -> dict:

104

"""

105

Remove rich menu from a specific user.

106

107

Args:

108

user_id: LINE user ID

109

110

Returns:

111

dict: Empty response on success

112

"""

113

114

def get_rich_menu_id_of_user(self, user_id: str) -> RichMenuIdResponse:

115

"""

116

Get the rich menu ID currently assigned to a user.

117

118

Args:

119

user_id: LINE user ID

120

121

Returns:

122

RichMenuIdResponse: Currently assigned rich menu ID

123

"""

124

```

125

126

### Bulk Rich Menu Operations

127

128

Perform rich menu operations on multiple users simultaneously.

129

130

```python { .api }

131

class MessagingApi:

132

def rich_menu_bulk_link(self, rich_menu_bulk_link_request: RichMenuBulkLinkRequest) -> dict:

133

"""

134

Link a rich menu to multiple users at once.

135

136

Args:

137

rich_menu_bulk_link_request: Bulk link configuration with user IDs and rich menu ID

138

139

Returns:

140

dict: Empty response on success

141

"""

142

143

def rich_menu_bulk_unlink(self, rich_menu_bulk_unlink_request: RichMenuBulkUnlinkRequest) -> dict:

144

"""

145

Unlink rich menus from multiple users at once.

146

147

Args:

148

rich_menu_bulk_unlink_request: Bulk unlink configuration with user IDs

149

150

Returns:

151

dict: Empty response on success

152

"""

153

```

154

155

### Rich Menu Aliases

156

157

Create and manage rich menu aliases for dynamic menu switching.

158

159

```python { .api }

160

class MessagingApi:

161

def create_rich_menu_alias(self, create_rich_menu_alias_request: CreateRichMenuAliasRequest) -> dict:

162

"""

163

Create an alias for a rich menu to enable programmatic switching.

164

165

Args:

166

create_rich_menu_alias_request: Alias configuration with rich menu ID and alias ID

167

168

Returns:

169

dict: Empty response on success

170

"""

171

172

def delete_rich_menu_alias(self, rich_menu_alias_id: str) -> dict:

173

"""

174

Delete a rich menu alias.

175

176

Args:

177

rich_menu_alias_id: Alias identifier to delete

178

179

Returns:

180

dict: Empty response on success

181

"""

182

183

def update_rich_menu_alias(self, rich_menu_alias_id: str, update_rich_menu_alias_request: UpdateRichMenuAliasRequest) -> dict:

184

"""

185

Update rich menu alias configuration.

186

187

Args:

188

rich_menu_alias_id: Alias identifier to update

189

update_rich_menu_alias_request: New alias configuration

190

191

Returns:

192

dict: Empty response on success

193

"""

194

195

def get_rich_menu_alias(self, rich_menu_alias_id: str) -> RichMenuAliasResponse:

196

"""

197

Get rich menu alias configuration.

198

199

Args:

200

rich_menu_alias_id: Alias identifier

201

202

Returns:

203

RichMenuAliasResponse: Alias configuration details

204

"""

205

206

def get_rich_menu_alias_list(self) -> RichMenuAliasListResponse:

207

"""

208

Get list of all rich menu aliases.

209

210

Returns:

211

RichMenuAliasListResponse: List of rich menu aliases

212

"""

213

```

214

215

### Batch Rich Menu Operations

216

217

Execute complex rich menu operations as batch jobs.

218

219

```python { .api }

220

class MessagingApi:

221

def rich_menu_batch(self, rich_menu_batch_request: RichMenuBatchRequest) -> dict:

222

"""

223

Execute batch rich menu operations (link, unlink, unlink all).

224

225

Args:

226

rich_menu_batch_request: Batch operation configuration

227

228

Returns:

229

dict: Empty response on success

230

"""

231

232

def get_rich_menu_batch_progress(self, request_id: str) -> RichMenuBatchProgressResponse:

233

"""

234

Get progress status of a batch rich menu operation.

235

236

Args:

237

request_id: Batch operation request identifier

238

239

Returns:

240

RichMenuBatchProgressResponse: Operation progress and status

241

"""

242

```

243

244

## Rich Menu Models

245

246

### Core Rich Menu Configuration

247

248

```python { .api }

249

class RichMenuRequest:

250

def __init__(

251

self,

252

size: RichMenuSize,

253

selected: bool,

254

name: str,

255

chat_bar_text: str,

256

areas: List[RichMenuArea]

257

):

258

"""

259

Rich menu configuration for creation.

260

261

Args:

262

size: Menu dimensions and layout

263

selected: Whether menu is initially displayed

264

name: Internal name for the rich menu

265

chat_bar_text: Text displayed on chat bar tab

266

areas: List of clickable areas with actions

267

"""

268

269

class RichMenuResponse:

270

rich_menu_id: str

271

size: RichMenuSize

272

selected: bool

273

name: str

274

chat_bar_text: str

275

areas: List[RichMenuArea]

276

277

class RichMenuSize:

278

def __init__(self, width: int, height: int):

279

"""

280

Rich menu dimensions.

281

282

Args:

283

width: Menu width (must be 2500px)

284

height: Menu height (1686px for full, 843px for half)

285

"""

286

287

class RichMenuArea:

288

def __init__(self, bounds: RichMenuBounds, action: Action):

289

"""

290

Clickable area within rich menu.

291

292

Args:

293

bounds: Rectangular area coordinates

294

action: Action to perform when area is tapped

295

"""

296

297

class RichMenuBounds:

298

def __init__(self, x: int, y: int, width: int, height: int):

299

"""

300

Rectangular area coordinates within rich menu.

301

302

Args:

303

x: Left edge X coordinate

304

y: Top edge Y coordinate

305

width: Area width

306

height: Area height

307

"""

308

```

309

310

### Rich Menu Alias Models

311

312

```python { .api }

313

class CreateRichMenuAliasRequest:

314

def __init__(self, rich_menu_alias_id: str, rich_menu_id: str):

315

"""

316

Request to create rich menu alias.

317

318

Args:

319

rich_menu_alias_id: Unique alias identifier

320

rich_menu_id: Target rich menu ID

321

"""

322

323

class UpdateRichMenuAliasRequest:

324

def __init__(self, rich_menu_id: str):

325

"""

326

Request to update rich menu alias target.

327

328

Args:

329

rich_menu_id: New target rich menu ID

330

"""

331

332

class RichMenuAliasResponse:

333

rich_menu_alias_id: str

334

rich_menu_id: str

335

336

class RichMenuAliasListResponse:

337

aliases: List[RichMenuAliasResponse]

338

```

339

340

### Bulk Operation Models

341

342

```python { .api }

343

class RichMenuBulkLinkRequest:

344

def __init__(self, rich_menu_id: str, user_ids: List[str]):

345

"""

346

Request to link rich menu to multiple users.

347

348

Args:

349

rich_menu_id: Rich menu identifier to link

350

user_ids: List of user IDs (max 500)

351

"""

352

353

class RichMenuBulkUnlinkRequest:

354

def __init__(self, user_ids: List[str]):

355

"""

356

Request to unlink rich menus from multiple users.

357

358

Args:

359

user_ids: List of user IDs (max 500)

360

"""

361

362

class RichMenuBatchRequest:

363

def __init__(self, operations: List[RichMenuBatchOperation]):

364

"""

365

Request for batch rich menu operations.

366

367

Args:

368

operations: List of batch operations to execute

369

"""

370

371

class RichMenuBatchOperation:

372

"""Base class for batch operations"""

373

type: str

374

375

class RichMenuBatchLinkOperation(RichMenuBatchOperation):

376

def __init__(self, rich_menu_id: str, user_ids: List[str]):

377

"""Batch operation to link rich menu to users."""

378

379

class RichMenuBatchUnlinkOperation(RichMenuBatchOperation):

380

def __init__(self, user_ids: List[str]):

381

"""Batch operation to unlink rich menus from users."""

382

383

class RichMenuBatchUnlinkAllOperation(RichMenuBatchOperation):

384

def __init__(self):

385

"""Batch operation to unlink all rich menus from all users."""

386

```

387

388

### Response Models

389

390

```python { .api }

391

class RichMenuIdResponse:

392

rich_menu_id: str

393

394

class RichMenuListResponse:

395

rich_menus: List[RichMenuResponse]

396

397

class RichMenuBatchProgressResponse:

398

phase: RichMenuBatchProgressPhase

399

accepted_time: str

400

completed_time: Optional[str] = None

401

402

class RichMenuBatchProgressPhase:

403

"""Enum: succeeded, failed, in_progress"""

404

pass

405

```

406

407

## Usage Examples

408

409

### Creating a Basic Rich Menu

410

411

```python

412

from linebot.v3.messaging import MessagingApi, Configuration

413

from linebot.v3.messaging.models import (

414

RichMenuRequest, RichMenuSize, RichMenuArea, RichMenuBounds,

415

PostbackAction, URIAction, MessageAction

416

)

417

418

# Initialize API client

419

config = Configuration(access_token='YOUR_ACCESS_TOKEN')

420

messaging_api = MessagingApi(config)

421

422

# Create rich menu configuration

423

rich_menu_request = RichMenuRequest(

424

size=RichMenuSize(width=2500, height=1686),

425

selected=True,

426

name="Main Menu",

427

chat_bar_text="Menu",

428

areas=[

429

RichMenuArea(

430

bounds=RichMenuBounds(x=0, y=0, width=833, height=843),

431

action=PostbackAction(data="menu=home", label="Home")

432

),

433

RichMenuArea(

434

bounds=RichMenuBounds(x=833, y=0, width=834, height=843),

435

action=PostbackAction(data="menu=products", label="Products")

436

),

437

RichMenuArea(

438

bounds=RichMenuBounds(x=1667, y=0, width=833, height=843),

439

action=URIAction(uri="https://example.com/contact", label="Contact")

440

),

441

RichMenuArea(

442

bounds=RichMenuBounds(x=0, y=843, width=1250, height=843),

443

action=MessageAction(text="Show my orders", label="My Orders")

444

),

445

RichMenuArea(

446

bounds=RichMenuBounds(x=1250, y=843, width=1250, height=843),

447

action=PostbackAction(data="menu=help", label="Help")

448

)

449

]

450

)

451

452

# Create the rich menu

453

response = messaging_api.create_rich_menu(rich_menu_request)

454

rich_menu_id = response.rich_menu_id

455

print(f"Created rich menu: {rich_menu_id}")

456

```

457

458

### Uploading Rich Menu Image

459

460

```python

461

from linebot.v3.messaging import MessagingApiBlob

462

463

blob_api = MessagingApiBlob(config)

464

465

# Upload background image

466

with open('rich_menu_image.jpg', 'rb') as image_file:

467

image_data = image_file.read()

468

469

blob_api.set_rich_menu_image(

470

rich_menu_id=rich_menu_id,

471

body=image_data,

472

content_type='image/jpeg'

473

)

474

print("Rich menu image uploaded successfully")

475

```

476

477

### Linking Rich Menu to Users

478

479

```python

480

# Link to specific user

481

messaging_api.link_rich_menu_id_to_user(

482

user_id="USER_ID_HERE",

483

rich_menu_id=rich_menu_id

484

)

485

486

# Bulk link to multiple users

487

from linebot.v3.messaging.models import RichMenuBulkLinkRequest

488

489

bulk_link_request = RichMenuBulkLinkRequest(

490

rich_menu_id=rich_menu_id,

491

user_ids=["user1", "user2", "user3"]

492

)

493

messaging_api.rich_menu_bulk_link(bulk_link_request)

494

```

495

496

### Dynamic Rich Menu Switching with Aliases

497

498

```python

499

from linebot.v3.messaging.models import (

500

CreateRichMenuAliasRequest, RichMenuSwitchAction

501

)

502

503

# Create aliases for different menu states

504

messaging_api.create_rich_menu_alias(

505

CreateRichMenuAliasRequest(

506

rich_menu_alias_id="main_menu",

507

rich_menu_id=main_menu_id

508

)

509

)

510

511

messaging_api.create_rich_menu_alias(

512

CreateRichMenuAliasRequest(

513

rich_menu_alias_id="settings_menu",

514

rich_menu_id=settings_menu_id

515

)

516

)

517

518

# Use RichMenuSwitchAction in buttons or areas

519

switch_action = RichMenuSwitchAction(

520

rich_menu_alias_id="settings_menu",

521

data="switched_to_settings"

522

)

523

```

524

525

### Advanced Rich Menu Management

526

527

```python

528

# Get all rich menus

529

menu_list = messaging_api.get_rich_menu_list()

530

for menu in menu_list.rich_menus:

531

print(f"Menu: {menu.name} (ID: {menu.rich_menu_id})")

532

533

# Check user's current rich menu

534

try:

535

user_menu = messaging_api.get_rich_menu_id_of_user("USER_ID")

536

print(f"User's current menu: {user_menu.rich_menu_id}")

537

except Exception as e:

538

print("User has no rich menu assigned")

539

540

# Batch operations for complex scenarios

541

from linebot.v3.messaging.models import (

542

RichMenuBatchRequest, RichMenuBatchLinkOperation,

543

RichMenuBatchUnlinkOperation

544

)

545

546

batch_request = RichMenuBatchRequest(

547

operations=[

548

RichMenuBatchUnlinkOperation(user_ids=["user1", "user2"]),

549

RichMenuBatchLinkOperation(

550

rich_menu_id=new_menu_id,

551

user_ids=["user1", "user2", "user3"]

552

)

553

]

554

)

555

messaging_api.rich_menu_batch(batch_request)

556

```

557

558

### Rich Menu Templates

559

560

```python

561

# Template for e-commerce bot

562

def create_ecommerce_menu():

563

return RichMenuRequest(

564

size=RichMenuSize(width=2500, height=843), # Half height

565

selected=True,

566

name="E-commerce Menu",

567

chat_bar_text="Shop",

568

areas=[

569

RichMenuArea( # Categories

570

bounds=RichMenuBounds(x=0, y=0, width=625, height=843),

571

action=PostbackAction(data="action=categories", label="Categories")

572

),

573

RichMenuArea( # Search

574

bounds=RichMenuBounds(x=625, y=0, width=625, height=843),

575

action=PostbackAction(data="action=search", label="Search")

576

),

577

RichMenuArea( # Cart

578

bounds=RichMenuBounds(x=1250, y=0, width=625, height=843),

579

action=PostbackAction(data="action=cart", label="Cart")

580

),

581

RichMenuArea( # Account

582

bounds=RichMenuBounds(x=1875, y=0, width=625, height=843),

583

action=PostbackAction(data="action=account", label="Account")

584

)

585

]

586

)

587

588

# Template for customer service bot

589

def create_support_menu():

590

return RichMenuRequest(

591

size=RichMenuSize(width=2500, height=1686), # Full height

592

selected=True,

593

name="Support Menu",

594

chat_bar_text="Help",

595

areas=[

596

RichMenuArea( # FAQ

597

bounds=RichMenuBounds(x=0, y=0, width=1250, height=843),

598

action=PostbackAction(data="support=faq", label="FAQ")

599

),

600

RichMenuArea( # Contact Agent

601

bounds=RichMenuBounds(x=1250, y=0, width=1250, height=843),

602

action=PostbackAction(data="support=agent", label="Talk to Agent")

603

),

604

RichMenuArea( # Track Issue

605

bounds=RichMenuBounds(x=0, y=843, width=833, height=843),

606

action=PostbackAction(data="support=track", label="Track Issue")

607

),

608

RichMenuArea( # Submit Feedback

609

bounds=RichMenuBounds(x=833, y=843, width=834, height=843),

610

action=PostbackAction(data="support=feedback", label="Feedback")

611

),

612

RichMenuArea( # Return to Main

613

bounds=RichMenuBounds(x=1667, y=843, width=833, height=843),

614

action=RichMenuSwitchAction(

615

rich_menu_alias_id="main_menu",

616

data="menu=main"

617

)

618

)

619

]

620

)

621

```