Introduction

Timing is a crucial aspect of building agentic contextual AI with Colang 2.0. The way your chatbot manages when to respond, follow up, or wait can make the difference between a robotic and a natural, engaging conversation. By controlling timing, you can add realism, provide helpful reminders, and keep users informed during longer processes.

In this lesson, you’ll learn how to use Colang’s timing commands to:

  • Add realistic delays to bot responses
  • Set up reminders or follow-ups when the user is silent
  • Trigger actions at regular intervals
Timing Commands in Colang 2.0

To use timing features in your Colang 2.0 flows, you need to import the CSL timing module at the top of your file:

Colang 2.0 provides several commands to help you manage timing in your chatbot flows. These commands let you pause, wait for silence, or schedule repeated actions.

  • wait $time_s $timer_id=...: Pauses the flow for a specified number of seconds.
  • bot was silent $time_s: Waits until the bot has not spoken for a certain time.
  • user was silent $time_s: Waits until the user has not said anything for a certain time.
  • user didnt respond $time_s: Waits for user silence, but only while the bot is also silent.
  • repeating timer $timer_id $interval_s: Starts a timer that triggers actions at regular intervals.
Delaying Bot Responses

You can use wait to add a short pause before your bot replies, making the conversation feel more natural.

This example makes the bot wait half a second between the two messages.

Detecting Bot Silence

To inform the user if the bot has not spoken for a while:

This keeps the user updated if something is taking time.

Waiting for User Silence

To check if the user has been quiet for a while:

This waits until the user has not said anything for 5 seconds, then sends a follow-up.

Waiting for User Response

If you want to remind the user only if both sides are silent:

This is useful for gentle reminders without interrupting the user.

Repeating Actions with Timers

To perform actions at regular intervals, use repeating timer:

This starts a timer called "my_timer" that triggers every 0.4 seconds. Each time the timer triggers, an event is published to the channel.

To handle this event, use:

This allows you to specify what should happen every time the timer fires.

Key Points and Best Practices
  • Use wait to add natural pauses to bot replies.
  • Use bot was silent, user was silent, and user didnt respond for reminders and follow-ups.
  • Use repeating timer for periodic actions.
  • Combine timing commands to create more human-like, responsive conversations.
  • Adjust timing values to fit your use case and user expectations.
Summary

Colang’s timing commands let you control when your bot responds, follows up, and performs actions. Mastering these tools helps you build chatbots that feel more natural and engaging. In the next practice, you’ll experiment with these timing features to see how they affect conversation flow.

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