AI

AI bot via OpenRouter

General Logic This is a demo bot connected to the OpenRouter model aggregator. Upon startup, the user enters the main menu and can choose from three scenarios: Dialogue with an AI habit coach — the bo...

Use template

General Logic

This is a demo bot connected to the OpenRouter model aggregator. Upon startup, the user enters the main menu and can choose from three scenarios:

  1. Dialogue with an AI habit coach — the bot maintains an ongoing conversation, helps formulate goals, tracks task completion, and motivates the user.
  2. Image generation — the user enters a text description; the bot then generates an image using the selected model and displays the result.
  3. Image analysis — the user sends a photo, and the bot passes it to the AI ​​to generate a text description.

All primary actions return the user either to a repeat of the current scenario or to the main menu. A unified screen with a notification and a "return" button handles integration errors.

The flow does not include a dedicated ai_dialog node type; AI functionality is implemented via OpenRouter integration blocks.

Startup and Main Menu

Upon startup, the bot opens the main menu, displaying a message about available actions and three inline buttons:

  • proceed to chat with the AI ​​coach;
  • proceed to image generation;
  • proceed to photo analysis.

The menu is also accessible via the bot's system menu. The buttons update the current message rather than creating a separate message thread.

The flow includes a visual frame describing the template's capabilities. This serves as an explanatory element within the editor and contains no executable blocks.

Functional Group: Dialogue with the AI ​​Coach

Message Input

First, the bot asks the user to enter a question or a report for the coach.

Text constraints:

  • minimum length: 5 characters;
  • maximum length: 1,000 characters;
  • an error message appears if constraints are violated;
  • an input cancellation button is provided.

Once the text is received, it is passed to the OpenRouter chat integration block. ### AI Message Processing

The openai/gpt-4o-mini model is used for the dialogue.

The system instruction defines the role of a personal discipline coach and habit tracker. The AI ​​must:

  • help the user formulate goals, including using the SMART format;
  • track daily task completion reports;
  • note progress and streaks of consecutive days;
  • motivate the user to keep going;
  • not indulge excessive excuses for missed tasks;
  • identify the real reason for any lapse;
  • speak confidently, energetically, and somewhat demandingly;
  • reply concisely—in about two or three sentences;
  • end every message with an open-ended question to keep the conversation going.

The response is structured in three stages:

  1. reaction to the user's action—praise or demanding feedback;
  2. motivational comment or progress assessment;
  3. question about the next step.

The conversation history is preserved, allowing the bot to maintain a continuous dialogue within a single user session. Message reprocessing is enabled via the integration: subsequent messages are routed to the same scenario until the user exits it via a different command or platform action.

Streaming and a typing indicator are enabled. A separate text block with a result template is disabled, as the response is likely sent directly by the integration block.

Functional Group: Image Generation

Obtaining the Description

After the user selects the generation option, the bot asks them to enter a description for the image.

Constraints for the description:

  • 5 to 1,000 characters;
  • a specific notification appears if the length is invalid;
  • input can be cancelled.

The entered text is saved to an internal variable and used as the generation prompt.

Image Creation

The description is sent to OpenRouter via the image generation operation. The google/gemini-2.5-flash-image model is used. The result is saved to a result variable. Uploading the image to Telegram is disabled at this stage; instead, the bot receives a link or address for the image and passes it to the next block for display.

Integration features include:

  • message reprocessing;
  • automatic retries upon error;
  • redirection to a dedicated error screen in case of failure.

Displaying the result

Upon successful generation, the bot displays the resulting image.

Two buttons are available to the user:

  • regenerate — enter a description again;
  • return to the main menu.

This allows the generation workflow to be used cyclically, enabling the creation of multiple images in succession.

Error handling

If OpenRouter fails to process the request, the bot displays an error message and offers to return to the main menu.

A dedicated handler manages image generation errors. The same error screen is also used by the image analysis workflow.

Functional group: image analysis

Waiting for a photo

After selecting the analysis option, the bot prompts the user to send an image.

Only the photo message type is accepted for input. If the user sends a different data type, a display...receives a message requesting a photo. Forwarding an image is also permitted.

Upon receipt of the photo, its identifier is saved and passed to the next block.

Image Analysis

The photo is sent to OpenRouter via the image analysis operation.

The openai/gpt-5-image-mini model is used. The request asks what is depicted in the photo. The received Telegram file identifier is passed as the image input.

Included features:

  • message reprocessing by the integration;
  • automatic retries;
  • transition to a general error screen upon failure.

Outputting the Description

Once analysis is complete, the bot sends a text description of the photo.

The user can:

  • send another photo for a new analysis;
  • return to the main menu.

Scenario Connections and Transitions

The transition logic is structured as follows:

  • startup leads to the main menu;
  • the chat button opens a text input field, then passes the text to the AI ​​coach;
  • the generation button opens a description input field, then triggers image creation;
  • the analysis button waits for a photo, then triggers image processing;
  • after generation, options to regenerate or return to the menu are available;
  • after analysis, options to re-analyze or return to the menu are available;
  • a generation or analysis error leads to a general error screen with an option to return to the menu.

Button-based transitions are implemented via callback actions, while transitions following the receipt of a valid message occur through the automatic continuation of the scenario.

Integrations and Required Settings

The workflow utilizes the OpenRouter integration with three operations:

  1. sending a text message to the AI;
  2. image generation;
  3. image analysis.

Requirements for operation:

  • connecting OpenRouter to the bot;
  • an OpenRouter API key;
  • an active OpenRouter account with a sufficient balance or credits;
  • access to the selected models within the account; - verification of compatibility between the current pricing plan/model and image generation and analysis capabilities;
  • a properly configured Telegram bot with permissions to receive photos and send images.

It is also necessary to verify that the generation output is returned in a format containing the image URL, as the subsequent block uses the link to the result to display it to the user.

Quick Setup

How to use the 'AI bot via OpenRouter' template in 6 easy steps

Step-by-step guide: from signing up to launching your AI assistant across Telegram, Web, and WhatsApp.

01
Sign up free

Create your free Botconsole account in 30 seconds. No credit card required.

02
Create a bot

Click "Create bot" in your dashboard to initiate a new automation project.

03
Connect a channel

Link your Telegram bot token from @BotFather, embed the Web Widget, or connect WhatsApp.

04
Apply the template

Open the visual flow builder and apply the ready-made "AI bot via OpenRouter" scenario in 1 click.

05
Customize to your brand

Edit messages, buttons, product catalogs, lead capture forms, or AI prompt instructions.

06
Publish & go live

Hit "Publish" — your automated chatbot assistant is live and ready to convert customers!

Use this template for free

Create a chatbot in Botconsole

Attract twice as many clients and generate sales on autopilot through messengers with Botconsole.