How can I validate the entire conversation in Dify in a real and automated way?

Hi, I would like to know if there is a real way to validate an entire conversation inside a Dify workflow, not just single responses or isolated messages.

Here is my use case:
I have an LLM that generates a JSON structure containing a full story (for example, a pirate-themed narrative using tags like [voice:name]). After the model generates this story, I need to validate the entire output against specific rules, such as confirming that the story starts with pirates, that Captain Barbanegra Rojo wants to steal the king’s gold, that the king’s daughter appears in the story, that the JSON format is correct, and that all voice tags are properly used.

I need this validation to happen automatically inside the workflow right after the story is generated. The goal is not to validate a single message, but the complete generated content — or even the entire conversation if necessary.

I would like to know if Dify currently offers any official mechanism to validate a full JSON output or multi-turn content, or if there is a recommended way to implement structured validation over the results produced by the LLM.

In short, I need Dify to take the complete JSON output from a previous step, analyze it, check whether it follows all the narrative rules I define, and then return something like “valid / invalid” along with a list of errors.

Is this possible with the current Dify tools, or is support for full conversation validation planned for future updates?

Here’s an example:

The story has to start with some pirates.

:robot:

Proceso de flujo de trabajo

:open_book: HISTORIA:
{
“content”: “[voice:narrador]: In the heart of the stormy seas, a fearsome pirate crew gathered on the deck of the ship known as The Tempest. [voice:antonio]: Ahoy, me hearties! They call me Blackbeard, captain of this cursed vessel, and I lead you into the depths of adventure! [voice:santiago]: I am Santiago, the cunning first mate, always ready to navigate through treacherous waters. [voice:sofia]: And I, Sofia, the fierce gunner, shall defend our ship with unmatched valor! [voice:jaime]: The treasure awaits, and I, Jaime, the swift hands of the crew, will be the first to claim it! [voice:veronica]: Beware! For the sea is full of dangers, and I, Veronica, the wise sage, can foresee the perils that lie ahead. [voice:leo]: But fear not, for luck is on our side. I, Leo, the charmer, can win over any foe we encounter. [voice:hernan]: Let them come! I am Hernan, the brutish fighter, and I shall crush any who dare oppose us! [voice:melina]: Together we sail, united in our quest for glory and gold! [voice:carla]: But remember, even the fiercest pirates face their reckoning. Let us tread carefully, for the sea remembers! [voice:matias]: And I shall make sure we remain stealthy, for I am Matias, the silent shadow of the crew. [voice:rodrigo]: What say ye, captain? Shall we set sail into the storm? [voice:antonio]: Aye! The winds favor us! Hoist the sails and let the adventure begin!”
}

Santiago He wants to steal the gold from the evil king.

:robot:

Proceso de flujo de trabajo

:open_book: HISTORIA:
{
“content”: “[voice:narrador]: As the crew gathered around the captain, Santiago stepped forward with a gleam in his eyes. [voice:santiago]: Aye, mates! I have a cunning plan to steal the gold from the evil king! [voice:antonio]: Speak, Santiago! What do you have in mind? [voice:sofia]: The king’s treasure is heavily guarded, we must be clever! [voice:jaime]: I can slip past their defenses, as silent as the night! [voice:veronica]: And I can sense the king’s movements, guiding us through the shadows. [voice:leo]: With my charm, I can distract the guards while you make your move! [voice:hernan]: And I will be ready to fight if things go awry! [voice:melina]: Together, we can achieve the impossible! [voice:carla]: But we must tread lightly; the king’s fury knows no bounds. [voice:matias]: Stealth is our ally, let us prepare for our daring heist! [voice:rodrigo]: Aye! The king will never see it coming! [voice:antonio]: Then it is settled! Prepare the ship, for we sail at dawn!”
}

Santiago He falls in love with the daughter of the evil king.

:robot:

Proceso de flujo de trabajo

:open_book: HISTORIA:
:open_book: HISTORIA:
{
“content”: “[voice:narrador]: As the days passed, Santiago found himself drawn to a figure that would change his fate. [voice:santiago]: I cannot help but admire her beauty from afar, the king’s daughter. [voice:sofia]: What madness is this, Santiago? She is the daughter of our enemy! [voice:jaime]: Love can be a dangerous game, my friend. [voice:veronica]: But perhaps she holds the key to our plan. [voice:leo]: If you win her heart, we may gain an ally within the castle! [voice:hernan]: Or a traitor among us! [voice:melina]: Be cautious, Santiago. The heart can lead us astray. [voice:carla]: Love and war are often intertwined; tread lightly! [voice:matias]: I can help you, Santiago. Stealth is my specialty, and I’ll ensure you meet her without alerting the guards. [voice:rodrigo]: Aye, but remember, if her father discovers this, it could mean doom for us all. [voice:santiago]: I know the risks, but I must try. For love is a treasure worth fighting for!”
}

Thanks to the daughter, they get the gold and get married, and it’s a happy ending.

:robot:

Proceso de flujo de trabajo

:open_book: HISTORIA:
:open_book: HISTORIA:
{
“content”: “[voice:narrador]: With the king’s daughter by his side, Santiago hatched a plan that would lead them to victory. [voice:santiago]: Together, we will steal the gold and secure our future! [voice:sofia]: I’ll provide cover fire while you make your move! [voice:jaime]: And I’ll create a diversion to keep the guards occupied! [voice:veronica]: I can sense the path to the treasure; follow my lead! [voice:leo]: With the charm of the princess, we can outsmart the king’s forces! [voice:hernan]: Let’s show them the true strength of our crew! [voice:melina]: Love will guide us through this perilous endeavor! [voice:carla]: And together, we shall claim what is rightfully ours! [voice:matias]: Stealth is our ally, and we will succeed! [voice:rodrigo]: The gold will be ours! [voice:narrador]: With the help of the king’s daughter, they executed their plan flawlessly and emerged victorious with the treasure. [voice:santiago]: With the gold in hand, I ask for your hand in marriage, my love! [voice:sofia]: A wedding for the ages! [voice:jaime]: Aye, let’s celebrate this union! [voice:veronica]: A new chapter begins! [voice:leo]: May their love shine brighter than any treasure! [voice:hernan]: Cheers to the happy couple! [voice:melina]: And to a life filled with adventure! [voice:carla]: Aye, let the celebrations begin! [voice:matias]: The sea has blessed us this day! [voice:rodrigo]: A tale for the ages, indeed!”
}
Here I want to use another model to validate everything.

what about using iteration node ?
so you need to construct the output into an array , then inside the iteration node you just validate your content;

You can use the LLM node’s Structured Output feature to specify the JSON schema for the output of the LLM node in a single round of conversation.

Although the LLM can also be used to validate the actual content afterwards, if strict validation is required, it’s a good idea to use code nodes.

To temporarily store all the interactions from multiple rounds of a conversation, it’s best to use Conversation Variables. If you add values to conversation variables in each round, you can freely retrieve the contents of previous conversations from the array in later steps.