Prompt Chaining 101: Mastering Prompt Chaining for Advanced AI Applications

Now that you’ve connected Flowise to your preferred LLM and created a handful of straightforward chatflows, what’s next? If you want to create more sophisticated and advanced AI applications, Multi-Prompt chains are the way to go.

Multi Prompt Chains allow you to create complex interactions that combine several chains and AI models to produce a desired output for an application. Think of it like creating a recipe with individual steps to create the final product. With each prompt in the chain you can create a template that tells the AI what to do next.

For instance, let’s imagine we’re tasked with designing a character for a video game using multi-chain prompts. To begin, we’d establish a general character type, such as a wizard, a dragon, a warrior, or any other imaginable archetype. Following that, we’d create a prompt defining the character’s environment, whether it’s a majestic castle, an ancient desert temple, or a lush jungle. Once we’ve nailed down the character and their surroundings, we’ll call a final prompt, instructing our AI to create a final description of our character that we can use in Midjourney to describe our character.

To get started with Multi-Chain prompting, let’s first open the Prompt chaining template from the Flowise marketplace



Next let’s add another set of a Prompt template, an LLM Chain and a Chat Model since we only have two sets right now in our chain. In this case we’ll be using Mistral Medium instead of OpenAI GPT for our Chat model.


The first prompt template is going to be our character profile creator, where we will enter an occupation for our main character and the the AI will generate details such as our characters name, origin, special skills and their main quest.




Here are all three prompt templates that you can copy and paste into your own chatflow:

Main Character Prompt Template #1: You are a fiction writer. Please create a name and detailed background profile given the character's their occupation provided in the context. 

Please also include where this character comes from, what their special abilities are, and what is their quest or mission. 

Character's Occupation:{occupation}


In the second template we take the output of the first prompt, in this case our character profile, and we send it to the second prompt where the AI will create a scene based on our character. Here’s the second prompt template:

Scene Environment Prompt Template #2: You are a talented artist and illustrator. Based on the following character information, describe an illustrated scene or a setting in whish we find our character. Be descriptive about the lighting, the time of day, where our character is at and what they are doing. 

Character: {scene}


Finally we take the scene description from template 2, and we use it as the context which will create our final prompt for Midjourney.

Midjourney Prompt Template #3: You are a midjourney artist prompting expert. Based on the follow character information and enviroment setting create a detailed midjourney prompt that best describes:(1) The Art Style, 2 The Character (3) The environment (4) Lighting (5) The Camera Angle

Please make your prompt no more than 500 characters

Character details and scene: {imagine}

Once you have setup all three prompt templates in your chatflow, you’ll need to connect the output of the first LLM chain to the second prompt and the output of the second LLM chain to the 3rd prompt.

This will allow you to (1) Create a Character Profile (2) Pass that Profile in the Scene Generator and (3) finally Create a Midjourney Prompt that you can use to generate an image.


While this is a simple layout, it does require some testing to make sure that your outputs are properly showing up as inputs for your follow-on prompts. If you don’t have Chatflow monitoring like LLM Monitor or Langfuse, then you’ll have run each prompt template separately before connecting them as chain.

You’ll also need to make sure that you’re prompt values are properly defined. We’ll cover prompt values in an future upcoming video.

Testing Your Chatflow

So initially, once I set everything up and ran the chatflow, I noticed that my character’s occupation was missing from my generated Character profile. This affected my entire flow, including my midjourney prompt at the end, so I had to to rewrite my character prompt template to make sure that the AI first created a profile around the character’s occupation such as pilot, wizard or warrior etc.

Once I did that, my chatflow started working the way I intended. Here’s an example using a Samurai Warrior as my initial prompt

Occupation: Samurai Warrior

Character Profile:

Name: Tatsuo Matsuda

Background: Born in the secluded village of Togakure in the mountains of Japan, Tatsuo Matsuda was raised in a family of samurai warriors, deeply rooted in the traditions of the ancient art of war. His father, a renowned samurai, trained him rigorously in the ways of the sword, the bow, and the mind. Tatsuo’s exceptional skills and unwavering dedication to the samurai code earned him the respect of his peers and the attention of the ruling shogunate.

Special Abilities: Tatsuo’s mastery of the samurai arts is unparalleled, with a particular aptitude for the katana, the traditional Japanese sword. He is also skilled in the art of stealth and camouflage, known as ninjutsu, which he learned from his mother, a descendant of the legendary ninja clan, the Koga. Tatsuo’s keen intellect and strategic mindset, coupled with his physical prowess, make him a formidable warrior.

Quest or Mission: When the shogunate faces a growing threat from a rogue daimyo, Tatsuo is entrusted with a critical mission. He must infiltrate the enemy’s stronghold, gather intelligence on their military capabilities, and neutralize their key commanders. As he navigates through treacherous territories and confronts deadly adversaries, Tatsuo remains steadfast in his quest to protect his people and uphold the honor of the samurai.


Next we create a scene for our Samurai Warrior:

The scene unfolds in the quiet stillness of twilight, as the sun dips below the horizon, casting a warm, golden glow over the landscape. Tatsuo Matsuda stands atop a rocky outcropping, overlooking a dense forest that stretches out before him. The forest, a sea of green, is illuminated by the fading light, with shadows dancing between the trees.

Tatsuo, dressed in his traditional samurai armor, riding his horse, with his katana sheathed at his side. His eyes, sharp and focused, scan the treeline, searching for any signs of movement. The air is thick with tension, as the forest holds its breath, waiting for the inevitable clash of steel and the dance of battle.

A gentle breeze rustles the leaves, whispering secrets to those who listen closely. Tatsuo’s ears, trained through years of rigorous discipline, pick up the faintest of sounds – the soft crunch of footsteps on the forest floor, the rustle of fabric against underbrush. He remains still, his body taut as a bowstring, ready to spring into action at a moment’s notice.

In the distance, the first stars begin to appear in the sky, their twinkling lights reflected in the still waters of a nearby lake. The forest, once a formidable barrier, seems to soften under the cover of night, offering Tatsuo a chance to slip through its grasp and complete his mission.

As the last vestiges of daylight fade, Tatsuo takes a deep breath, his chest rising and falling in the cool evening air. He knows that the path ahead is fraught with danger, but he is ready. With a swift, fluid motion, he draws his katana, the blade gleaming in the moonlight.

And so, under the watchful gaze of the stars, Tatsuo Matsuda embarks on his quest, a lone samurai warrior against the darkness of the night.


Finally we create our prompt for Midjourney:

Art Style: Stylized realism with bold lines and vibrant colors, reminiscent of comic book art.
Character: Tatsuo Matsuda, a samurai warrior in full armor, riding his horse, katana at his side
Environment: A dense forest at twilight, with a rocky outcropping overlooking the treeline
Lighting: Warm, golden light from the setting sun, contrasted with the cool, blue light of the moon Camera Angle: Low angle, looking up at Tatsuo to emphasize his strength and determination as he embarks on his quest.

And here is the final result in Midjourney:

And here are a few more images from our character creator. As you can see, the possibilities are endless.

Captain Raleigh Hawthorne – Pilot

Art Style: Detailed, atmospheric, and realistic with a touch of cyberpunk. Character: Captain Raleigh “Razor” Hawthorne – a battle-hardened pilot clad in a sleek, futuristic flight suit. His eyes are intense, his jaw is clenched, and his stance is confident. He holds a holographic map in front of him, absorbed in the data. Environment: An abandoned space station hangar. Neon lights flicker and cast eerie shadows on the worn and weathered walls. Dust particles float in the air, and the distant hum of machinery fills the background. The hangar doors are open, revealing a breathtaking view of the cosmos. Lighting: Dim and moody with flickering neon lights casting blue and purple hues across the hangar. The cosmos outside the hangar provides a striking contrast, with twinkling stars and a vibrant nebula casting their glow. Camera Angle: A dynamic, low-angle shot that captures the size of the hangar and the scope of the mission. The camera focuses on Razor and his team, with the Nightingale stealth fighter looming in the shadows in the background. As Razor issues orders, the camera moves in closer, capturing the intensity in his eyes and the determination on his face. –v 5.0

Aerin Aeriallis – Acrobat

Art Style: Illustrative, with a touch of realism and a focus on dynamic movement and expressive characters. Character: Aerin Aeriallis, a powerful aeromancer and acrobat, stands at the edge of a precipice, summoning a swirling vortex of wind around her. Clad in a form-fitting, deep blue bodysuit with golden filigree, she exudes confidence and determination. Her long, auburn hair is adorned with Zephyros Blossoms and golden threads, which flutter in the wind. Environment: Windwhisper Grove, a lush and sacred sanctuary hidden among the trees, teeming with vibrant foliage and delicate silver-blue flowers. The city of Serendell can be seen in the distance, bathed in the warm, golden light of the late afternoon sun. The towering tents and colorful banners of the Cirque du Elytheria flutter in the breeze. Lighting: Soft, radiant light bathes the scene, casting a warm golden hue over the landscape. The sun is low in the sky, creating long, dramatic shadows and highlighting the texture and detail of the environment. Camera Angle: The camera is positioned at a low angle, slightly below Aerin and looking up at her as she stands atop the precipice. This angle emphasizes her power and confidence, while also showcasing the swirling vortex of wind that surrounds her. The background of the city and the Cirque du Elytheria are visible in the distance, providing context and depth to the scene.

Share the Post:

Flowise Chain Node Mastery (Mini-Course)

Picture of Level: Intermediate

Level: Intermediate

Flowise Training

Level: Intermediate Training

Discover How to use Chains Nodes in Flowise to Build Powerful AI Applications

Chain nodes are the building blocks of Flowise, a powerful tool for creating conversational AI applications. These nodes enable you to perform a wide range of tasks, from retrieving data from APIs and databases to generating responses using large language models. In this mini course, you will learn about the different chain nodes available in Flowise and how to use them to build sophisticated conversational AI applications.

Here’s What You’ll Learn:

  • How each of the chain node works and how to use them in Flowise.
  • Which nodes have been replaced by newer tools and updates.
  • How to connect to a variety of APIs to extend the power of your Chatflows and AI applications
  • How to use the SQL Database Chain to interact with SQL databases using natural language
  • When to use prompt chains vs retrieval chains in your workflows
  • How to add chat models in your chains that might not be supported yet in Flowise
  • How to create multi-prompt chains as well as retrieval QA chains that can handle multiple documents.

By the end of this mini course, you will have a better understanding of the different chain nodes available in Flowise and how to use them to build sophisticated conversational AI applications.

You will also learn best practices for improving the performance of your chains, handling errors, and formatting your data and loading documents for your RAG (Retrieval) applications.


Course Content

8 Sections | 4 Lectures | 50 Minutes Total Length

Lesson 1: API Chains

In this lesson we’ll look at the API Chains including the GET and POST Chain as wel as the OpenAI API Chain. These Chains are used to connect to a variety of third party APIs for integration with Flowise.

Project Files: Open Movie Review Chatbot (POST | GET Request)
Lesson 2: Database Chains

In this lesson, we’ll expore our database chains, including the SQL Database Chain, Vectara QA Chain and the VectorDB QA Chain. These chains help you connect to and query a database.

In the case of the SQL Chain, it will use SQL query language to query a database based on your questions. The Vectara and Vector DB chains connect to a vector database in order to summarize and answer questions based on your documents. 

Project Files: SQL Database Chain

In this project, we've created our own SQL database with data from the Open Movie Database to test in our SQL Chain in Flowise

Lesson 3: Retrieval QA Chains

Retrieval QA Chains are a core feature of Flowise that allow you to build powerful Retrieval Augmented Generation or RAG applications. 

In this lesson, we’ll look at each of the Retrieval QA chains and sh

Project Files: Retrieval QA Chains
Lesson 4: LLM Prompt Chains

LLM Prompt Chains allow us to add Prompt Templates to our chatflows and customise exacly how we want our LLMs to respond to our queries or user input. 

Prompt templates also allow you to add additional information from previous nodes, allowing you to create multistep workflows based on what you need your application to do.

In this lesson, we’ll look at three nodes, The LLM Chain, The Conversation Chain and the Multi Prompt Chain. Each one can be connected to chat prompt templates so you can create complex conversational workflows that leverage the power of large language models (LLMs)

Project Files: LLM Prompt Chains

In this project, we'll create an App Idea Generator using LLM prompt chaining

Review Q+A

In this session, we'll answer some common questions about Flowise including:
1. How can I improve the performance of a chain in Flowise?(i.e improving quality of responses, Reduce hallucinations, increasing speed etc)
2. What is the best way to connect multiple chain nodes in Flowise?
3. How can I use chat models in my chains that might not be supported yet in Flowise
4. What is the best way to load documents for retrieval (PDF, CSV, TXT etc)
5. How do I handle errors in a chain in Flowise?
6. How do I format the output of a Retrieval QA Chain in Flowise?
7. How to create a Retrieval QA Chain that can handle multiple documents in Flowise?
8. What do I need to make sure that values are passed between chain nodes?
9. Is it possible to use a form with many inputs in Flowise instead of the chat input method?
10. How to create a chain that can handle large datasets in Flowise?

Contact Us