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

messaging.mddocs/

0

# Core Messaging

1

2

Core messaging functionality for sending messages through the LINE platform including push messages, reply messages, multicast, broadcast, and user profile management. This module provides the essential capabilities for bot communication and user interaction.

3

4

## Capabilities

5

6

### Message Sending

7

8

Send messages to users through various delivery methods including direct push, reply to events, multicast to multiple users, and broadcast to all followers.

9

10

```python { .api }

11

class MessagingApi:

12

def reply_message(self, reply_message_request: ReplyMessageRequest) -> ReplyMessageResponse:

13

"""

14

Reply to user messages or events using reply tokens.

15

16

Args:

17

reply_message_request: Reply message configuration with token and messages

18

19

Returns:

20

ReplyMessageResponse: Sent message metadata

21

"""

22

23

def push_message(self, push_message_request: PushMessageRequest) -> PushMessageResponse:

24

"""

25

Send messages directly to users without reply tokens.

26

27

Args:

28

push_message_request: Push message configuration with recipient and messages

29

30

Returns:

31

PushMessageResponse: Sent message metadata

32

"""

33

34

def multicast(self, multicast_request: MulticastRequest) -> dict:

35

"""

36

Send messages to multiple specific users.

37

38

Args:

39

multicast_request: Multicast configuration with user IDs and messages

40

41

Returns:

42

dict: Empty response on success

43

"""

44

45

def broadcast(self, broadcast_request: BroadcastRequest) -> dict:

46

"""

47

Send messages to all bot followers.

48

49

Args:

50

broadcast_request: Broadcast configuration with messages and filters

51

52

Returns:

53

dict: Empty response on success

54

"""

55

56

def narrowcast(self, narrowcast_request: NarrowcastRequest) -> dict:

57

"""

58

Send targeted messages to specific audience segments.

59

60

Args:

61

narrowcast_request: Narrowcast configuration with audience and messages

62

63

Returns:

64

dict: Empty response on success

65

"""

66

```

67

68

### Message Validation

69

70

Validate message objects before sending to ensure proper formatting and compliance with LINE platform requirements.

71

72

```python { .api }

73

class MessagingApi:

74

def validate_reply_message_objects(self, validate_message_request: ValidateMessageRequest) -> dict:

75

"""Validate reply message objects for proper formatting."""

76

77

def validate_push_message_objects(self, validate_message_request: ValidateMessageRequest) -> dict:

78

"""Validate push message objects for proper formatting."""

79

80

def validate_multicast_message_objects(self, validate_message_request: ValidateMessageRequest) -> dict:

81

"""Validate multicast message objects for proper formatting."""

82

83

def validate_broadcast_message_objects(self, validate_message_request: ValidateMessageRequest) -> dict:

84

"""Validate broadcast message objects for proper formatting."""

85

86

def validate_narrowcast_message_objects(self, validate_message_request: ValidateMessageRequest) -> dict:

87

"""Validate narrowcast message objects for proper formatting."""

88

```

89

90

### User Profile Management

91

92

Access user profile information, group and room details, and manage user interactions.

93

94

```python { .api }

95

class MessagingApi:

96

def get_profile(self, user_id: str) -> UserProfileResponse:

97

"""

98

Get user profile information.

99

100

Args:

101

user_id: LINE user ID

102

103

Returns:

104

UserProfileResponse: User profile data including display name and picture

105

"""

106

107

def get_group_summary(self, group_id: str) -> GroupSummaryResponse:

108

"""

109

Get group information and member count.

110

111

Args:

112

group_id: LINE group ID

113

114

Returns:

115

GroupSummaryResponse: Group metadata and member information

116

"""

117

118

def get_group_members_count(self, group_id: str) -> GroupMemberCountResponse:

119

"""Get total member count in a group."""

120

121

def get_group_member_profile(self, group_id: str, user_id: str) -> GroupUserProfileResponse:

122

"""Get user profile within a specific group context."""

123

124

def get_room_member_count(self, room_id: str) -> RoomMemberCountResponse:

125

"""Get total member count in a room."""

126

127

def get_room_member_profile(self, room_id: str, user_id: str) -> RoomUserProfileResponse:

128

"""Get user profile within a specific room context."""

129

```

130

131

### Bot Information

132

133

Retrieve bot-specific information and configuration details.

134

135

```python { .api }

136

class MessagingApi:

137

def get_bot_info(self) -> BotInfoResponse:

138

"""

139

Get bot profile information including display name, user ID, and basic settings.

140

141

Returns:

142

BotInfoResponse: Bot profile metadata

143

"""

144

```

145

146

### Message Content and Media

147

148

Handle message content retrieval and transcoding for media messages.

149

150

```python { .api }

151

class MessagingApiBlob:

152

def get_message_content(self, message_id: str) -> bytes:

153

"""

154

Retrieve binary content from media messages.

155

156

Args:

157

message_id: Message ID containing media content

158

159

Returns:

160

bytes: Binary content data

161

"""

162

163

def get_message_content_preview(self, message_id: str) -> bytes:

164

"""Get preview/thumbnail version of media content."""

165

166

def get_message_content_transcoding_by_message_id(self, message_id: str) -> GetMessageContentTranscodingResponse:

167

"""Get transcoding status and information for video content."""

168

```

169

170

### Message Quota Management

171

172

Monitor and manage message quota usage and consumption.

173

174

```python { .api }

175

class MessagingApi:

176

def get_message_quota(self) -> MessageQuotaResponse:

177

"""

178

Get current message quota limits and usage.

179

180

Returns:

181

MessageQuotaResponse: Quota limits and consumption data

182

"""

183

184

def get_message_quota_consumption(self) -> QuotaConsumptionResponse:

185

"""Get detailed message quota consumption statistics."""

186

```

187

188

### Message Statistics

189

190

Access message delivery statistics and performance metrics.

191

192

```python { .api }

193

class MessagingApi:

194

def get_number_of_sent_reply_messages(self, date: str) -> NumberOfMessagesResponse:

195

"""Get count of reply messages sent on specific date."""

196

197

def get_number_of_sent_push_messages(self, date: str) -> NumberOfMessagesResponse:

198

"""Get count of push messages sent on specific date."""

199

200

def get_number_of_sent_multicast_messages(self, date: str) -> NumberOfMessagesResponse:

201

"""Get count of multicast messages sent on specific date."""

202

203

def get_number_of_sent_broadcast_messages(self, date: str) -> NumberOfMessagesResponse:

204

"""Get count of broadcast messages sent on specific date."""

205

```

206

207

### Loading Animation

208

209

Show loading animations to users during processing.

210

211

```python { .api }

212

class MessagingApi:

213

def show_loading_animation(self, show_loading_animation_request: ShowLoadingAnimationRequest) -> dict:

214

"""

215

Display loading animation to user while processing requests.

216

217

Args:

218

show_loading_animation_request: Configuration for loading animation display

219

220

Returns:

221

dict: Empty response on success

222

"""

223

```

224

225

### Message Reading Management

226

227

Mark messages as read to improve user experience and chat organization.

228

229

```python { .api }

230

class MessagingApi:

231

def mark_messages_as_read(self, mark_messages_as_read_request: MarkMessagesAsReadRequest) -> dict:

232

"""

233

Mark messages as read in one-on-one, group, or room chat.

234

235

Args:

236

mark_messages_as_read_request: Configuration with chat reference and message details

237

238

Returns:

239

dict: Empty response on success

240

"""

241

```

242

243

### Link Token Management

244

245

Issue link tokens for account linking functionality.

246

247

```python { .api }

248

class MessagingApi:

249

def issue_link_token(self, user_id: str) -> IssueLinkTokenResponse:

250

"""

251

Issue a link token for account linking with external services.

252

253

Args:

254

user_id: User ID for the LINE account to be linked

255

256

Returns:

257

IssueLinkTokenResponse: Link token for account linking

258

"""

259

```

260

261

### Group and Room Management

262

263

Leave groups and rooms when needed for bot management.

264

265

```python { .api }

266

class MessagingApi:

267

def leave_group(self, group_id: str) -> dict:

268

"""

269

Leave a group chat.

270

271

Args:

272

group_id: Group ID to leave

273

274

Returns:

275

dict: Empty response on success

276

"""

277

278

def leave_room(self, room_id: str) -> dict:

279

"""

280

Leave a room chat.

281

282

Args:

283

room_id: Room ID to leave

284

285

Returns:

286

dict: Empty response on success

287

"""

288

289

def get_group_members_ids(self, group_id: str, start: Optional[str] = None) -> MembersIdsResponse:

290

"""

291

Get list of user IDs of members in a group.

292

293

Args:

294

group_id: Group ID

295

start: Continuation token for pagination

296

297

Returns:

298

MembersIdsResponse: List of member IDs and next token

299

"""

300

301

def get_room_members_ids(self, room_id: str, start: Optional[str] = None) -> MembersIdsResponse:

302

"""

303

Get list of user IDs of members in a room.

304

305

Args:

306

room_id: Room ID

307

start: Continuation token for pagination

308

309

Returns:

310

MembersIdsResponse: List of member IDs and next token

311

"""

312

```

313

314

### Webhook Endpoint Management

315

316

Manage webhook endpoints for receiving LINE platform events.

317

318

```python { .api }

319

class MessagingApi:

320

def get_webhook_endpoint(self) -> GetWebhookEndpointResponse:

321

"""

322

Get the current webhook endpoint URL.

323

324

Returns:

325

GetWebhookEndpointResponse: Current webhook endpoint configuration

326

"""

327

328

def set_webhook_endpoint(self, set_webhook_endpoint_request: SetWebhookEndpointRequest) -> dict:

329

"""

330

Set the webhook endpoint URL.

331

332

Args:

333

set_webhook_endpoint_request: New webhook endpoint configuration

334

335

Returns:

336

dict: Empty response on success

337

"""

338

339

def test_webhook_endpoint(self, test_webhook_endpoint_request: TestWebhookEndpointRequest) -> TestWebhookEndpointResponse:

340

"""

341

Test the webhook endpoint configuration.

342

343

Args:

344

test_webhook_endpoint_request: Test webhook configuration

345

346

Returns:

347

TestWebhookEndpointResponse: Test results and status

348

"""

349

```

350

351

## Request and Response Models

352

353

### Request Models

354

355

```python { .api }

356

class ReplyMessageRequest:

357

reply_token: str

358

messages: List[Message]

359

notification_disabled: Optional[bool] = None

360

361

class PushMessageRequest:

362

to: str # User ID, group ID, or room ID

363

messages: List[Message]

364

notification_disabled: Optional[bool] = None

365

custom_aggregation_units: Optional[List[str]] = None

366

367

class MulticastRequest:

368

to: List[str] # List of user IDs

369

messages: List[Message]

370

notification_disabled: Optional[bool] = None

371

custom_aggregation_units: Optional[List[str]] = None

372

373

class BroadcastRequest:

374

messages: List[Message]

375

notification_disabled: Optional[bool] = None

376

custom_aggregation_units: Optional[List[str]] = None

377

378

class NarrowcastRequest:

379

messages: List[Message]

380

recipient: Recipient

381

filter: Optional[Filter] = None

382

limit: Optional[Limit] = None

383

notification_disabled: Optional[bool] = None

384

385

class ValidateMessageRequest:

386

messages: List[Message]

387

388

class MarkMessagesAsReadRequest:

389

chat_reference: ChatReference

390

391

class SetWebhookEndpointRequest:

392

endpoint: str

393

394

class TestWebhookEndpointRequest:

395

endpoint: str

396

```

397

398

### Response Models

399

400

```python { .api }

401

class ReplyMessageResponse:

402

sent_messages: List[SentMessage]

403

404

class PushMessageResponse:

405

sent_messages: List[SentMessage]

406

407

class UserProfileResponse:

408

display_name: str

409

user_id: str

410

language: str

411

picture_url: Optional[str] = None

412

status_message: Optional[str] = None

413

414

class GroupSummaryResponse:

415

group_id: str

416

group_name: str

417

picture_url: Optional[str] = None

418

419

class GroupMemberCountResponse:

420

count: int

421

422

class BotInfoResponse:

423

basic_id: str

424

premium_id: Optional[str] = None

425

display_name: str

426

picture_url: Optional[str] = None

427

chat_mode: str

428

mark_as_read_mode: str

429

430

class MessageQuotaResponse:

431

type: QuotaType

432

value: int

433

434

class NumberOfMessagesResponse:

435

status: str

436

success: Optional[int] = None

437

438

class IssueLinkTokenResponse:

439

link_token: str

440

441

class GetWebhookEndpointResponse:

442

endpoint: str

443

active: bool

444

445

class TestWebhookEndpointResponse:

446

success: bool

447

timestamp: str

448

status_code: int

449

reason: str

450

detail: str

451

452

class MembersIdsResponse:

453

member_ids: List[str]

454

next: Optional[str] = None

455

456

class ChatReference:

457

type: str # "user", "group", or "room"

458

id: str

459

```

460

461

### Sent Message Models

462

463

```python { .api }

464

class SentMessage:

465

id: str

466

quota_consumption: Optional[int] = None

467

468

class QuotaType:

469

"""Enum for quota types: none, limited"""

470

pass

471

```

472

473

## Usage Examples

474

475

### Basic Message Sending

476

477

```python

478

from linebot.v3.messaging import MessagingApi, Configuration

479

from linebot.v3.messaging.models import TextMessage, ReplyMessageRequest

480

481

# Initialize API client

482

config = Configuration(access_token='YOUR_ACCESS_TOKEN')

483

messaging_api = MessagingApi(config)

484

485

# Reply to a message event

486

reply_request = ReplyMessageRequest(

487

reply_token=event.reply_token,

488

messages=[TextMessage(text="Hello, World!")]

489

)

490

response = messaging_api.reply_message(reply_request)

491

492

# Push message to specific user

493

push_request = PushMessageRequest(

494

to="USER_ID_HERE",

495

messages=[TextMessage(text="Push notification message")]

496

)

497

messaging_api.push_message(push_request)

498

```

499

500

### Multicast to Multiple Users

501

502

```python

503

from linebot.v3.messaging.models import MulticastRequest, TextMessage

504

505

multicast_request = MulticastRequest(

506

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

507

messages=[

508

TextMessage(text="Important announcement to selected users")

509

]

510

)

511

messaging_api.multicast(multicast_request)

512

```

513

514

### User Profile Retrieval

515

516

```python

517

# Get user profile

518

profile = messaging_api.get_profile("USER_ID")

519

print(f"User: {profile.display_name}")

520

print(f"Language: {profile.language}")

521

522

# Get group information

523

group_info = messaging_api.get_group_summary("GROUP_ID")

524

print(f"Group: {group_info.group_name}")

525

```

526

527

### Message Quota Monitoring

528

529

```python

530

# Check current quota

531

quota = messaging_api.get_message_quota()

532

print(f"Quota type: {quota.type}")

533

print(f"Remaining: {quota.value}")

534

535

# Get usage statistics

536

stats = messaging_api.get_number_of_sent_push_messages("20240101")

537

print(f"Push messages sent: {stats.success}")

538

```