Simple Time-Based routing for FreeSWITCH using Python

Here is a quick and dirty script I wrote that will use python to do Time Based Routing. This is useful for people using a dynamic source of their XML dialplan (such as WikiPBX) who cannot use the normal

method.

#!/usr/local/bin/python
from freeswitch import *
import datetime

def input_callback(session, what, obj):
	return 

def handler(session, args):

	the_uuid = session.getVariable("uuid")
	session.answer()
	now = datetime.datetime.now()
	if now.hour >= 16 and now.hour <=21:
		session.execute("ivr", "YourIVRNameHere")
        else:
        	session.execute("voicemail", "ProfileName DomainName MailboxName")
	return

Leave a Reply