Time-Based Routing

Routing Asterisk 18+ -- Last reviewed 2026-03-29 routing time-conditions business-hours Found this useful? Upvote it. ×

Time-Based Routing

Route incoming calls differently depending on the time of day, day of week, and holidays.

Requirements

Dialplan

[incoming]
exten => s,1,Answer()
 same => n,GotoIfTime(*,*,25,dec?holiday,s,1)
 same => n,GotoIfTime(*,*,1,jan?holiday,s,1)
 same => n,GotoIfTime(09:00-17:00,mon-fri,*,*?open,s,1)
 same => n,Goto(closed,s,1)

[open]
exten => s,1,NoOp(Business hours -- route to queue)
 same => n,Goto(main-queue,s,1)

[closed]
exten => s,1,NoOp(After hours)
 same => n,Playback(custom/after-hours)
 same => n,Goto(voicemail-main,s,1)

[holiday]
exten => s,1,NoOp(Holiday greeting)
 same => n,Playback(custom/holiday-greeting)
 same => n,Goto(voicemail-main,s,1)

How it works

  1. GotoIfTime(time,dow,dom,month?context,ext,pri): Evaluates the current time against the given pattern. If it matches, execution jumps to the specified destination.
  2. Pattern fields: The four fields are: time range, day-of-week, day-of-month, and month. Use * as a wildcard for any field.
  3. Evaluation order matters: Asterisk evaluates GotoIfTime top to bottom. Place more specific rules (holidays) before general ones so they are evaluated first.
  4. Fallthrough: If no GotoIfTime matches, execution continues to the next priority, which is the Goto(closed,...) fallback.

Tips

User Notes

No notes yet. Be the first to contribute a tip or example.

Contribute a note

Share a tip, gotcha, or practical example. Keep it under 2000 characters. No questions (use the Asterisk community forums for support). Wrap code in backticks.

Moderated before publishing. Email never shown.

Related Snippets