πŸ’¬ Generate text & image responses in Telegram channels with GPT-4 and TGPT

⚑ 417 views Β· πŸ’¬ Support Chatbots

Description

Telegram AI Channel Bot - Text & Image Response Generator with TGPT

Overview

This n8n workflow creates an automated Telegram channel bot that responds to messages with AI-generated text or images using TGPT. The bot monitors a specific Telegram channel and generates responses based on message prefixes.

Features

Setup Instructions

Prerequisites

  1. n8n Instance: Ensure you have n8n installed and running
  2. Telegram Bot: Create a new bot via @BotFather on Telegram
  3. Telegram Channel: Create or have admin access to a Telegram channel
  4. Linux Environment: The workflow requires Linux for command execution

Configuration Steps

1. Obtain Telegram Bot Token

2. Get Channel ID

3. Configure the Workflow

4. Set Up Telegram Credentials in n8n

5. System Requirements

The workflow automatically installs required packages:

Activation

How to Use

Sending Commands to the Bot

Text Generation

To generate a text response, send a message to your Telegram channel with the following format:

am# Your prompt here

Example:

am# Explain quantum computing in simple terms

The bot will:

  1. Remove the am# prefix
  2. Send the prompt to TGPT with GPT-4 model
  3. Generate a response with temperature 0.3 (more focused/deterministic)
  4. Reply with the generated text in the channel

Image Generation

To generate an image, send a message with this format:

ami# Your image description here

Example:

ami# A futuristic city with flying cars at sunset

The bot will:

  1. Remove the ami# prefix
  2. Use TGPT to generate an image (1920x1080 resolution)
  3. Save the image temporarily
  4. Send the generated image to the channel

Important Usage Notes

Response Time

Message Processing

Limitations

Troubleshooting

Bot Not Responding

  1. Verify the workflow is active
  2. Check that the bot is an admin in the channel
  3. Confirm the channel ID is correct (negative number for channels)
  4. Ensure messages start with exact prefixes: am# or ami#

Duplicate Responses

Missing Dependencies

Performance Issues

Advanced Configuration

Modify Polling Interval

Edit the Schedule node to change the 10-second interval

Adjust Time Window

In the Process Offset node, modify timeWindowSeconds variable (default: 15)

Change AI Model Parameters

Customize Image Dimensions

In Execute - Image node, modify:

Security Considerations

Maintenance

πŸ”— Nodes Used

HTTP Request, Telegram, Schedule Trigger, Read/Write Files from Disk

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup