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
Delaying Bot Responses

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

bot say "Message #1"
wait 0.5
bot say "Message #2"

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:

bot was silent 2.0
bot say "Please hold on, this is taking a bit longer than expected."

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:

user was silent 5.0
bot say "5 seconds have passed - are you still there?"

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:

user didnt respond 5.0
bot say "How can I help you today?"

This is useful for gentle reminders without interrupting the user.

Repeating Actions with Timers

To perform actions at regular intervals, use repeating timer:

repeating timer "my_timer" 0.4

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:

match TimerBotAction.Finished(timer_name="my_timer")

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