# Telegram Bot Template

## `Build A Skillful Telegram Bot`

<figure><img src="https://2166271580-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS0TAZCNsj3CIFMwFkHtG%2Fuploads%2F9mN5Ha2OAk3nVcuwcDe5%2Fimage.png?alt=media&#x26;token=7523e109-23e1-4fa1-9509-ea8b4deebbb7" alt=""><figcaption><p>Skillful Agent Integration Example</p></figcaption></figure>

Create your own AI-powered Telegram bot in minutes using our template. This guide will walk you through setting up and deploying your first Skillful AI agent on Telegram.

### `Prerequisites`

Before you begin, you'll need:

* A Telegram account
* A Skillful AI API key
* Node.js installed on your computer

### `1. Create a Telegram Bot`

1. Open Telegram and search for "@BotFather"
2. Start a chat with BotFather
3. Send the `/newbot` command
4. Follow the prompts to:
   * Choose a name for your bot (e.g., "My Skillful Bot")
   * Choose a username (must end in 'bot', e.g., "my\_skillful\_bot")
5. BotFather will provide you with a token - save this for later

### `2. Set Up Your Project`

Using a code editor like **Visual Studio Code**, we can create a new project with:

```bash
# Create a new project directory
mkdir my-telegram-bot
cd my-telegram-bot

# Install the template
npm install @skillfulai/telegram-template
```

### `3. Configure Environment Variables`

Create a `.env` file in your project root:

```env
TELEGRAM_TOKEN=your_telegram_bot_token    # From BotFather
SKILLFUL_API_KEY=your_skillful_api_key    # Your Skillful AI API key
AGENT_NAME=Wojak                          # Name of the agent you want to use
```

### `4. Create Your Bot`

Create a file named `index.js` and add the following code to it:

```javascript
const SkillfulTelegramBot = require('@skillfulai/telegram-template');

// Initialize and start the bot
const bot = new SkillfulTelegramBot();
bot.initialize().then(() => {
    console.log('Bot is running...');
}).catch(error => {
    console.error('Failed to start bot:', error);
});
```

### `5. Run Your Bot`

Start your bot:

```bash
node index.js
```

That's it! Your bot is now running. Open Telegram and search for your bot's username to start chatting.

### `Available Commands`

Your bot comes with several built-in commands:

* `/start` - Get a welcome message and overview
* `/info` - View detailed agent information
* `/skills` - See all available capabilities
* `/clear` - Reset the conversation
* `/status` - Check bot status

### `Testing Your Bot`

Try these interactions to test your bot:

1. Send `/start` to see the welcome message
2. Use `/skills` to view available capabilities
3. Ask general questions to test conversation
4. Use `/info` to see technical details

### `Troubleshooting`

If you encounter issues:

1. Check that your tokens are correct in `.env`
2. Ensure your Skillful AI API key is valid
3. Verify the agent name exists in your account
4. Check the console for any error messages

### `Next Steps`

Now that your bot is running, you can:

* Customize the agent's personality
* Add more skills through the Skillful AI dashboard
* Modify the template code to add custom features
* Deploy to a hosting service for 24/7 availability

Need help? Join our [Discord community](https://discord.gg/WhAYqkXYkg)
