Send your Telegram bot a description and it draws that picture and sends it back to the same chat.

UsesImgBBOpenAIStability AITelegram

Message a description, get a picture back in Telegram

Whenever a message arrives in the chat your Telegram bot watches, the description in it is checked for safety, drawn as a picture in the style and shape you have chosen, and sent back to the same chat as a photo captioned with what was asked for.

The picture goes back only to the chat that asked for it. Every request passes a safety check first: the AI is asked whether the description is one the bot should draw, and a picture is only made on a clear yes. Real or identifiable people, sexual, violent or hateful content, anything meant to pass as a real document or brand, and instructions for making a weapon or a drug are refused, and the chat is told why. If the check does not come back, or the picture cannot be made or hosted, you get a plain message rather than silence. The bot's own replies are recognized and left alone.

Before the first run you need a Telegram bot in the chat, an image generator and an image host, which keeps a public copy for a week so Telegram can fetch it.

TelegramTelegramWhen a new message is received. Save it as incomingMessage.When a new message is received. Save it as incomingMessage.
Set pictureStyle to blank.Set pictureStyle to blank.
Set pictureShape to “1:1”.Set pictureShape to “1:1”.
TextMake pictureStyle lowercase and save it as styleChoice.Make pictureStyle lowercase and save it as styleChoice.
Set knownStyles to:Set knownStyles to:3d-model analog-film anime cinematic comic-book digital-art enhance fantasy-art isometric line-art low-poly modeling-compound neon-punk origami photographic pixel-art ...
If knownStyles doesn't contain styleChoiceIf knownStyles doesn't contain styleChoice
Yes
Stop and report a problem: The 'pictureStyle' step is not a style the image generator knows. Use one of: 3d-model, analog-film, anime, cinematic, comic-book, digital-art, enhance, fantasy-art, isometric, line-art, low-poly, modeling-compound, neon-punk, origami, photographic, pixel-art or tile-texture.Stop and report a problem: The 'pictureStyle' step is not a style the image generator knows. Use one of: 3d-model, analog-film, anime, cinematic, comic-book, digital-art, enhance, fantasy-art, isometric, line-art, low-poly, modeling-compound, neon-punk, origami, photographic, pixel-art or tile-texture.
No
No steps
Trim pictureShape and save it as shapeChoice.Trim pictureShape and save it as shapeChoice.
Set knownShapes to:Set knownShapes to:1:1 16:9 9:16 3:2 2:3 5:4 4:5 21:9 9:21
If knownShapes doesn't contain shapeChoiceIf knownShapes doesn't contain shapeChoice
Yes
Stop and report a problem: The 'pictureShape' step is not a shape the image generator knows. Use one of: 1:1, 16:9, 9:16, 3:2, 2:3, 5:4, 4:5, 21:9 or 9:21.Stop and report a problem: The 'pictureShape' step is not a shape the image generator knows. Use one of: 1:1, 16:9, 9:16, 3:2, 2:3, 5:4, 4:5, 21:9 or 9:21.
No
No steps
Set chatId to incomingMessage.chat_id.Set chatId to incomingMessage.chat_id.
If chatId is emptyIf chatId is empty
Yes
Stop and report a problem: That message did not say which chat it came from, so there was nowhere to send a picture back to.Stop and report a problem: That message did not say which chat it came from, so there was nowhere to send a picture back to.
No
No steps
Set requestText to blank.Set requestText to blank.
If a step below fails, save the error as messageErrorIf a step below fails, save the error as messageError
Try
Trim incomingMessage.text and save it as requestText.Trim incomingMessage.text and save it as requestText.
On error
Finish the run: That message had no text in it, so there was nothing to draw.Finish the run: That message had no text in it, so there was nothing to draw.
Set isOwnReply to requestText starts with “Here is your picture” or requestText starts with “I could not draw that” or requestText starts with “Tell me what to draw”.Set isOwnReply to requestText starts with “Here is your picture” or requestText starts with “I could not draw that” or requestText starts with “Tell me what to draw”.
If isOwnReply is yesIf isOwnReply is yes
Yes
Finish the run: That message was one this workflow sent, so it was left alone.Finish the run: That message was one this workflow sent, so it was left alone.
No
No steps
If the length of requestText is less than 3If the length of requestText is less than 3
Yes
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.Tell me what to draw - a red bicycle leaning on a wall at sunset, a fox reading a map, anything you can describe.
Finish the run: The message did not describe a picture, so nothing was drawn.Finish the run: The message did not describe a picture, so nothing was drawn.
No
No steps
Shorten requestText to 400 characters (keeping words whole) and save it as cappedRequest.Shorten requestText to 400 characters (keeping words whole) and save it as cappedRequest.
Set screenRules to You are the safety check for a picture bot. Someone has sent a description and a picture will be drawn from it. Decide whether it should be drawn.Set screenRules to You are the safety check for a picture bot. Someone has sent a description and a picture will be drawn from it. Decide whether it should be drawn. Refuse if the description asks for: - any real, named or otherwise identifiable person, living or dead, including public figures, politicians, celebrities, and anyone the sender says they know - sexual or suggestive content of anyone, or any depiction of a child that is not ordinary and fully clothed - violence, gore, injury, self-harm, or a weapon being used on someone - hateful, demeaning or harassing content about a person or a group - anything meant to pass as real: an identity document, currency, an official paper, a signature, or the logo or packaging of a real company or product - a diagram or instructions for making a weapon, an explosive or a drug Anything else is fine, including invented characters, animals, places, food, objects, patterns, abstract art and fictional scenes.
Set screenPrompt to screenRulesAnswer on one line. Either the single word ALLOW, or REFUSE: followed by one short sentence, beginning with a capital letter, that a person can read and that says what the problem was without repeating the request.Set screenPrompt to screenRulesAnswer on one line. Either the single word ALLOW, or REFUSE: followed by one short sentence, beginning with a capital letter, that a person can read and that says what the problem was without repeating the request. The description: cappedRequest .
Set screenResult to nothing.Set screenResult to nothing.
If a step below fails, save the error as screenCallErrorIf a step below fails, save the error as screenCallError
Try
OpenAIOpenAIAsk OpenAI: screenPrompt. Save it as screenResult.Ask OpenAI: screenPrompt. Save it as screenResult.
On error
Change screenResult to nothing.Change screenResult to nothing.
Set verdict to blank.Set verdict to blank.
If a step below fails, save the error as verdictErrorIf a step below fails, save the error as verdictError
Try
Trim screenResult.response_text and save it as verdict.Trim screenResult.response_text and save it as verdict.
On error
Change verdict to blank.Change verdict to blank.
If verdict doesn't start with “ALLOW”If verdict doesn't start with “ALLOW”
Yes
Set refusalText to “I could not draw that. The safety check did not come back, so nothing was drawn. Send the description again in a moment.”.Set refusalText to “I could not draw that. The safety check did not come back, so nothing was drawn. Send the description again in a moment.”.
If verdict starts with “REFUSE”If verdict starts with “REFUSE”
Yes
Trim verdict with “REFUSE:” replaced by “” with “REFUSE” replaced by “” and save it as refusalReason.Trim verdict with “REFUSE:” replaced by “” with “REFUSE” replaced by “” and save it as refusalReason.
Change refusalText to “I could not draw that. It is outside what this bot will draw.”.Change refusalText to “I could not draw that. It is outside what this bot will draw.”.
If refusalReason isn't emptyIf refusalReason isn't empty
Yes
Change refusalText to “I could not draw that. refusalReason truncated to 300 characters using “...” as the ellipsis (keeping words whole)”.Change refusalText to “I could not draw that. refusalReason truncated to 300 characters using “...” as the ellipsis (keeping words whole)”.
No
No steps
No
No steps
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.refusalText
Finish the run: The request was not cleared by the safety check, so no picture was drawn.Finish the run: The request was not cleared by the safety check, so no picture was drawn.
No
No steps
Set pictureRef to blank.Set pictureRef to blank.
If a step below fails, save the error as drawingErrorIf a step below fails, save the error as drawingError
Try
Stability AIStability AIGenerate an image of cappedRequest. Save it as generated.Generate an image of cappedRequest. Save it as generated.text, letters, words, watermark, signature, logo, brand mark, real person, celebrity, nudity, gore
Trim generated.document_ref and save it as pictureRef.Trim generated.document_ref and save it as pictureRef.
On error
Change pictureRef to blank.Change pictureRef to blank.
Set pictureUrl to blank.Set pictureUrl to blank.
If pictureRef isn't emptyIf pictureRef isn't empty
Yes
If a step below fails, save the error as hostingErrorIf a step below fails, save the error as hostingError
Try
ImgBBImgBBUpload an image. Save it as hosted.Upload an image. Save it as hosted.
Trim hosted.url and save it as pictureUrl.Trim hosted.url and save it as pictureUrl.
On error
Change pictureUrl to blank.Change pictureUrl to blank.
No
No steps
If pictureUrl doesn't start with “https://”If pictureUrl doesn't start with “https://”
Yes
Change pictureUrl to blank.Change pictureUrl to blank.
No
No steps
If pictureUrl isn't emptyIf pictureUrl isn't empty
Yes
TelegramTelegramSend a photo to chat chatId.Send a photo to chat chatId. Photo URL: pictureUrlHere is your picture: cappedRequest truncated to 900 characters using "..." as the ellipsis (keeping words whole)
Finish the run: The picture was drawn and sent back to the chat it was asked for in.Finish the run: The picture was drawn and sent back to the chat it was asked for in.
No
No steps
TelegramTelegramSend a message to chat chatId.Send a message to chat chatId.I could not draw that right now - the picture could not be made. Send the description again in a moment.
Finish the run: No picture could be made, so the chat was told instead.Finish the run: No picture could be made, so the chat was told instead.