or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

advanced-features.mdbot-settings.mdbot-setup.mdchat-management.mdindex.mdinteractive-features.mdmedia-files.mdmessage-handling.mdmessaging.md

bot-settings.mddocs/

0

# Bot Information and Settings

1

2

Bot configuration and information management including commands, descriptions, menu buttons, and administrator rights.

3

4

## Capabilities

5

6

### Bot Information

7

8

Methods for retrieving and managing basic bot information.

9

10

```javascript { .api }

11

/**

12

* Get bot information

13

* @param {object} [options] - Additional options

14

* @returns {Promise<User>}

15

*/

16

getMe(options): Promise<User>;

17

18

/**

19

* Log out bot from cloud API

20

* @param {object} [options] - Additional options

21

* @returns {Promise<boolean>}

22

*/

23

logOut(options): Promise<boolean>;

24

25

/**

26

* Close bot instance and free resources

27

* @param {object} [options] - Additional options

28

* @returns {Promise<boolean>}

29

*/

30

close(options): Promise<boolean>;

31

```

32

33

**Usage Example:**

34

35

```javascript

36

// Get bot information

37

const botInfo = await bot.getMe();

38

console.log('Bot username:', botInfo.username);

39

console.log('Bot first name:', botInfo.first_name);

40

console.log('Bot ID:', botInfo.id);

41

console.log('Can join groups:', botInfo.can_join_groups);

42

console.log('Can read all group messages:', botInfo.can_read_all_group_messages);

43

console.log('Supports inline queries:', botInfo.supports_inline_queries);

44

45

// Log out from cloud API (for local Bot API server)

46

const loggedOut = await bot.logOut();

47

if (loggedOut) {

48

console.log('Bot logged out successfully');

49

}

50

51

// Close bot instance

52

const closed = await bot.close();

53

if (closed) {

54

console.log('Bot closed successfully');

55

}

56

```

57

58

### Bot Commands

59

60

Methods for managing the bot's command menu and help interface.

61

62

```javascript { .api }

63

/**

64

* Set bot's command list

65

* @param {object[]} commands - Array of bot commands

66

* @param {object} [options] - Command scope and language options

67

* @returns {Promise<boolean>}

68

*/

69

setMyCommands(commands, options): Promise<boolean>;

70

71

/**

72

* Delete bot's commands

73

* @param {object} [options] - Scope and language options

74

* @returns {Promise<boolean>}

75

*/

76

deleteMyCommands(options): Promise<boolean>;

77

78

/**

79

* Get bot's current commands

80

* @param {object} [options] - Scope and language options

81

* @returns {Promise<BotCommand[]>}

82

*/

83

getMyCommands(options): Promise<BotCommand[]>;

84

```

85

86

**Usage Example:**

87

88

```javascript

89

// Set general commands for all users

90

await bot.setMyCommands([

91

{ command: 'start', description: 'Start the bot' },

92

{ command: 'help', description: 'Get help information' },

93

{ command: 'settings', description: 'Configure bot settings' },

94

{ command: 'about', description: 'About this bot' }

95

]);

96

97

// Set commands for specific scope (group administrators)

98

await bot.setMyCommands([

99

{ command: 'ban', description: 'Ban a user' },

100

{ command: 'unban', description: 'Unban a user' },

101

{ command: 'promote', description: 'Promote user to admin' },

102

{ command: 'demote', description: 'Remove admin privileges' }

103

], {

104

scope: {

105

type: 'all_chat_administrators'

106

}

107

});

108

109

// Set commands for specific language

110

await bot.setMyCommands([

111

{ command: 'start', description: 'Iniciar el bot' },

112

{ command: 'ayuda', description: 'Obtener información de ayuda' },

113

{ command: 'configuracion', description: 'Configurar el bot' }

114

], {

115

language_code: 'es'

116

});

117

118

// Set commands for specific chat

119

await bot.setMyCommands([

120

{ command: 'stats', description: 'Show chat statistics' },

121

{ command: 'backup', description: 'Backup chat data' }

122

], {

123

scope: {

124

type: 'chat',

125

chat_id: chatId

126

}

127

});

128

129

// Get current commands

130

const commands = await bot.getMyCommands();

131

console.log('Current commands:');

132

commands.forEach(cmd => {

133

console.log(`/${cmd.command} - ${cmd.description}`);

134

});

135

136

// Get commands for specific scope

137

const adminCommands = await bot.getMyCommands({

138

scope: {

139

type: 'all_chat_administrators'

140

}

141

});

142

143

// Delete all commands

144

await bot.deleteMyCommands();

145

146

// Delete commands for specific scope

147

await bot.deleteMyCommands({

148

scope: {

149

type: 'all_private_chats'

150

}

151

});

152

```

153

154

### Bot Profile

155

156

Methods for managing bot's profile information like name and description.

157

158

```javascript { .api }

159

/**

160

* Set bot's name

161

* @param {object} [options] - Name options

162

* @returns {Promise<boolean>}

163

*/

164

setMyName(options): Promise<boolean>;

165

166

/**

167

* Get bot's name

168

* @param {object} [options] - Language options

169

* @returns {Promise<BotName>}

170

*/

171

getMyName(options): Promise<BotName>;

172

173

/**

174

* Set bot's description (shown in chat info)

175

* @param {object} [options] - Description options

176

* @returns {Promise<boolean>}

177

*/

178

setMyDescription(options): Promise<boolean>;

179

180

/**

181

* Get bot's description

182

* @param {object} [options] - Language options

183

* @returns {Promise<BotDescription>}

184

*/

185

getMyDescription(options): Promise<BotDescription>;

186

187

/**

188

* Set bot's short description (shown in search results)

189

* @param {object} [options] - Short description options

190

* @returns {Promise<boolean>}

191

*/

192

setMyShortDescription(options): Promise<boolean>;

193

194

/**

195

* Get bot's short description

196

* @param {object} [options] - Language options

197

* @returns {Promise<BotShortDescription>}

198

*/

199

getMyShortDescription(options): Promise<BotShortDescription>;

200

```

201

202

**Usage Example:**

203

204

```javascript

205

// Set bot name

206

await bot.setMyName({

207

name: 'My Awesome Bot'

208

});

209

210

// Set bot name for specific language

211

await bot.setMyName({

212

name: 'Mi Bot Increíble',

213

language_code: 'es'

214

});

215

216

// Get bot name

217

const botName = await bot.getMyName();

218

console.log('Bot name:', botName.name);

219

220

// Set bot description

221

await bot.setMyDescription({

222

description: 'This is an awesome bot that helps you manage your daily tasks and provides useful information. It can handle various commands and interact with multiple services.'

223

});

224

225

// Set description for specific language

226

await bot.setMyDescription({

227

description: 'Este es un bot increíble que te ayuda a gestionar tus tareas diarias y proporciona información útil.',

228

language_code: 'es'

229

});

230

231

// Get bot description

232

const botDescription = await bot.getMyDescription();

233

console.log('Bot description:', botDescription.description);

234

235

// Set short description (for search results)

236

await bot.setMyShortDescription({

237

short_description: 'Task management and utility bot'

238

});

239

240

// Set short description for specific language

241

await bot.setMyShortDescription({

242

short_description: 'Bot de gestión de tareas y utilidades',

243

language_code: 'es'

244

});

245

246

// Get short description

247

const shortDesc = await bot.getMyShortDescription();

248

console.log('Short description:', shortDesc.short_description);

249

```

250

251

### Chat Menu Button

252

253

Methods for configuring the menu button in private chats.

254

255

```javascript { .api }

256

/**

257

* Set chat menu button

258

* @param {object} [options] - Menu button options

259

* @returns {Promise<boolean>}

260

*/

261

setChatMenuButton(options): Promise<boolean>;

262

263

/**

264

* Get chat menu button

265

* @param {object} [options] - Chat options

266

* @returns {Promise<MenuButton>}

267

*/

268

getChatMenuButton(options): Promise<MenuButton>;

269

```

270

271

**Usage Example:**

272

273

```javascript

274

// Set default menu button (shows "Menu")

275

await bot.setChatMenuButton({

276

menu_button: {

277

type: 'default'

278

}

279

});

280

281

// Set commands menu button

282

await bot.setChatMenuButton({

283

menu_button: {

284

type: 'commands'

285

}

286

});

287

288

// Set web app menu button

289

await bot.setChatMenuButton({

290

menu_button: {

291

type: 'web_app',

292

text: 'Open Dashboard',

293

web_app: {

294

url: 'https://mybot.example.com/dashboard'

295

}

296

}

297

});

298

299

// Set menu button for specific chat

300

await bot.setChatMenuButton({

301

chat_id: chatId,

302

menu_button: {

303

type: 'web_app',

304

text: 'Chat Settings',

305

web_app: {

306

url: `https://mybot.example.com/chat/${chatId}/settings`

307

}

308

}

309

});

310

311

// Get current menu button

312

const menuButton = await bot.getChatMenuButton();

313

console.log('Menu button type:', menuButton.type);

314

315

if (menuButton.type === 'web_app') {

316

console.log('Web app text:', menuButton.text);

317

console.log('Web app URL:', menuButton.web_app.url);

318

}

319

320

// Get menu button for specific chat

321

const chatMenuButton = await bot.getChatMenuButton({

322

chat_id: chatId

323

});

324

```

325

326

### Administrator Rights

327

328

Methods for managing bot's default administrator rights.

329

330

```javascript { .api }

331

/**

332

* Set default administrator rights for the bot

333

* @param {object} [options] - Administrator rights options

334

* @returns {Promise<boolean>}

335

*/

336

setMyDefaultAdministratorRights(options): Promise<boolean>;

337

338

/**

339

* Get default administrator rights

340

* @param {object} [options] - Rights scope options

341

* @returns {Promise<ChatAdministratorRights>}

342

*/

343

getMyDefaultAdministratorRights(options): Promise<ChatAdministratorRights>;

344

```

345

346

**Usage Example:**

347

348

```javascript

349

// Set default admin rights for groups

350

await bot.setMyDefaultAdministratorRights({

351

rights: {

352

is_anonymous: false,

353

can_manage_chat: true,

354

can_delete_messages: true,

355

can_manage_video_chats: true,

356

can_restrict_members: true,

357

can_promote_members: false,

358

can_change_info: false,

359

can_invite_users: true,

360

can_pin_messages: true,

361

can_manage_topics: true

362

},

363

for_channels: false

364

});

365

366

// Set different rights for channels

367

await bot.setMyDefaultAdministratorRights({

368

rights: {

369

is_anonymous: false,

370

can_manage_chat: true,

371

can_delete_messages: false,

372

can_manage_video_chats: false,

373

can_restrict_members: false,

374

can_promote_members: false,

375

can_change_info: false,

376

can_invite_users: false,

377

can_post_messages: true,

378

can_edit_messages: true,

379

can_pin_messages: true,

380

can_manage_topics: false

381

},

382

for_channels: true

383

});

384

385

// Get default admin rights for groups

386

const groupRights = await bot.getMyDefaultAdministratorRights({

387

for_channels: false

388

});

389

390

console.log('Default group admin rights:');

391

console.log('Can manage chat:', groupRights.can_manage_chat);

392

console.log('Can delete messages:', groupRights.can_delete_messages);

393

console.log('Can restrict members:', groupRights.can_restrict_members);

394

395

// Get default admin rights for channels

396

const channelRights = await bot.getMyDefaultAdministratorRights({

397

for_channels: true

398

});

399

400

console.log('Default channel admin rights:');

401

console.log('Can post messages:', channelRights.can_post_messages);

402

console.log('Can edit messages:', channelRights.can_edit_messages);

403

```

404

405

### Configuration Management

406

407

Example patterns for managing bot configuration and settings.

408

409

**Usage Example:**

410

411

```javascript

412

// Complete bot setup function

413

async function setupBot() {

414

// Get bot info

415

const botInfo = await bot.getMe();

416

console.log(`Setting up bot: ${botInfo.first_name} (@${botInfo.username})`);

417

418

// Set commands

419

await bot.setMyCommands([

420

{ command: 'start', description: 'Start the bot' },

421

{ command: 'help', description: 'Show help information' },

422

{ command: 'settings', description: 'Bot settings' },

423

{ command: 'about', description: 'About this bot' }

424

]);

425

426

// Set bot name and descriptions

427

await bot.setMyName({ name: 'Task Manager Bot' });

428

await bot.setMyDescription({

429

description: 'A comprehensive task management bot that helps you organize your daily activities, set reminders, and track your productivity.'

430

});

431

await bot.setMyShortDescription({

432

short_description: 'Task management and productivity bot'

433

});

434

435

// Set default admin rights

436

await bot.setMyDefaultAdministratorRights({

437

rights: {

438

can_manage_chat: true,

439

can_delete_messages: true,

440

can_restrict_members: true,

441

can_invite_users: true,

442

can_pin_messages: true

443

}

444

});

445

446

// Set menu button

447

await bot.setChatMenuButton({

448

menu_button: {

449

type: 'web_app',

450

text: 'Open Dashboard',

451

web_app: { url: 'https://taskbot.example.com/dashboard' }

452

}

453

});

454

455

console.log('Bot setup completed successfully!');

456

}

457

458

// Configuration validation

459

async function validateBotConfig() {

460

try {

461

const [commands, botName, description, shortDesc, adminRights, menuButton] = await Promise.all([

462

bot.getMyCommands(),

463

bot.getMyName(),

464

bot.getMyDescription(),

465

bot.getMyShortDescription(),

466

bot.getMyDefaultAdministratorRights(),

467

bot.getChatMenuButton()

468

]);

469

470

console.log('✅ Bot configuration validation:');

471

console.log(`Commands: ${commands.length} configured`);

472

console.log(`Name: ${botName.name || 'Not set'}`);

473

console.log(`Description: ${description.description ? 'Set' : 'Not set'}`);

474

console.log(`Short description: ${shortDesc.short_description ? 'Set' : 'Not set'}`);

475

console.log(`Admin rights: ${Object.keys(adminRights).length} permissions configured`);

476

console.log(`Menu button: ${menuButton.type}`);

477

478

return true;

479

} catch (error) {

480

console.error('❌ Bot configuration validation failed:', error.message);

481

return false;

482

}

483

}

484

485

// Initialize bot with full configuration

486

setupBot().then(() => {

487

console.log('Bot is ready!');

488

validateBotConfig();

489

});

490

```

491

492

## Types

493

494

```javascript { .api }

495

interface User {

496

id: number;

497

is_bot: boolean;

498

first_name: string;

499

last_name?: string;

500

username?: string;

501

language_code?: string;

502

is_premium?: boolean;

503

added_to_attachment_menu?: boolean;

504

can_join_groups?: boolean;

505

can_read_all_group_messages?: boolean;

506

supports_inline_queries?: boolean;

507

}

508

509

interface BotCommand {

510

command: string;

511

description: string;

512

}

513

514

interface BotCommandScope {

515

type: 'default' | 'all_private_chats' | 'all_group_chats' | 'all_chat_administrators' | 'chat' | 'chat_administrators' | 'chat_member';

516

chat_id?: number | string;

517

user_id?: number;

518

}

519

520

interface BotName {

521

name: string;

522

}

523

524

interface BotDescription {

525

description: string;

526

}

527

528

interface BotShortDescription {

529

short_description: string;

530

}

531

532

interface MenuButton {

533

type: 'commands' | 'web_app' | 'default';

534

}

535

536

interface MenuButtonWebApp extends MenuButton {

537

type: 'web_app';

538

text: string;

539

web_app: WebApp;

540

}

541

542

interface WebApp {

543

url: string;

544

}

545

546

interface ChatAdministratorRights {

547

is_anonymous: boolean;

548

can_manage_chat: boolean;

549

can_delete_messages: boolean;

550

can_manage_video_chats: boolean;

551

can_restrict_members: boolean;

552

can_promote_members: boolean;

553

can_change_info: boolean;

554

can_invite_users: boolean;

555

can_post_messages?: boolean;

556

can_edit_messages?: boolean;

557

can_pin_messages: boolean;

558

can_post_stories?: boolean;

559

can_edit_stories?: boolean;

560

can_delete_stories?: boolean;

561

can_manage_topics: boolean;

562

}

563

564

interface SetMyCommandsOptions {

565

scope?: BotCommandScope;

566

language_code?: string;

567

}

568

569

interface SetMyNameOptions {

570

name?: string;

571

language_code?: string;

572

}

573

574

interface SetMyDescriptionOptions {

575

description?: string;

576

language_code?: string;

577

}

578

579

interface SetMyShortDescriptionOptions {

580

short_description?: string;

581

language_code?: string;

582

}

583

584

interface SetChatMenuButtonOptions {

585

chat_id?: number | string;

586

menu_button?: MenuButton;

587

}

588

589

interface SetMyDefaultAdministratorRightsOptions {

590

rights?: ChatAdministratorRights;

591

for_channels?: boolean;

592

}

593

```