Introduction

Previously, you learned how to control chatbot response timing in Colang using delays and reminders. As your bots become more sophisticated, you’ll need advanced tools to manage how conversations flow—especially when handling repeated actions, cleaning up after tasks, or customizing behaviors. This is where advanced flow management comes in.

In this lesson, you’ll learn how to:

  • Start new instances of flows to handle repeated or overlapping user actions
  • Deactivate flows to stop them when they’re no longer needed
  • Override flows to change or extend their behavior

These techniques make your chatbots more flexible and robust.

Starting New Flow Instances

Colang flows are the backbone of conversation handling. By default, you can activate a flow using the activate keyword, which ensures the flow restarts automatically when triggered again. However, this approach has a limitation: if a user repeats the same action before the previous flow instance finishes, the bot may not respond as expected.

To address this, Colang provides a way to start a completely new instance of a flow—even if another instance is already running—using the start_new_flow_instance label.

Example:

Key Points:

  • activate keeps a flow running and restarts it when triggered, but only one instance runs at a time.
  • start_new_flow_instance: allows multiple instances of the same flow to run in parallel, so repeated user actions are always handled.

This is especially useful for handling rapid or overlapping user inputs.

Deactivating Flows

Sometimes, you need to stop a flow from running—such as when a user leaves a conversation or completes a task. Colang provides the deactivate keyword for this purpose.

Example:

Key Points:

  • deactivate prevents it from restarting automatically.

Deactivating flows helps you manage resources and prevent unwanted responses in complex conversations.

Overriding Flows

As your chatbot evolves, you may want to change how certain flows behave without rewriting everything. Colang supports this with the @override decorator, which lets you replace or extend existing flows.

Example:

Key Points:

  • Use @override to replace a flow’s previous definition.
  • This is especially useful for customizing behaviors from imported modules or standard flows.

Overriding flows keeps your code modular and maintainable.

Summary

Advanced flow management in Colang lets you:

  • Start new flow instances for repeated or overlapping actions
  • Deactivate flows to clean up or control conversation state
  • Override flows to customize or extend behavior

These tools help you build chatbots that are responsive, flexible, and easy to maintain. In the next practice, you’ll apply these techniques to real-world scenarios.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal