Renaming / Duplicating the wizard dial plans

Feedback, issues & questions regarding the use of the Telis Wizard and Simple Wizard dial plans.
raj2ras
Posts: 132
Joined: Tue Nov 08, 2011 2:13 am

Renaming / Duplicating the wizard dial plans

Postby raj2ras » Thu Dec 08, 2011 5:04 am

Aaron,

Awesome job on the "Simple Wizard" dial plan. If you could add a feature to rename them and duplicate them, that would help. Currently no easy way to do it on any of the wizard DPs.

User avatar
Aaron
Site Admin
Posts: 4550
Joined: Thu Jul 12, 2007 12:13 am

Re: Renaming / Duplicating the wizard dial plans

Postby Aaron » Thu Dec 08, 2011 10:36 am

Ok I'll add the request to the list. In regards to the duplication why would you do that?

raj2ras
Posts: 132
Joined: Tue Nov 08, 2011 2:13 am

Re: Renaming / Duplicating the wizard dial plans

Postby raj2ras » Fri Dec 09, 2011 2:04 am

Duplication just for testing/backup of different routing scenarios.

Also, do the wizards create/link to a "Ruby script" in the back? Is there any way to export/dump it out to a .txt file ? Lets say as one's Ruby skill improves, one can manipulate them further at code level.

User avatar
Aaron
Site Admin
Posts: 4550
Joined: Thu Jul 12, 2007 12:13 am

Re: Renaming / Duplicating the wizard dial plans

Postby Aaron » Sun Dec 11, 2011 12:41 am

The Ruby script behind the Simple Wizard is as below. It's unlikely to be that useful since it doesn't create a normal line by line script of call forwards. Instead it works by retrieving and processing each simple wizard rule from a database table.

As an alternative you could take a look at mnipp's wizard at http://free2call.me/rubywizard.html which does generate a line-by-line script.

Code: Select all

def ProcessMatch(matchedRule)
   sys.Log("SimpleWizard matched on rule with #{matchedRule.Pattern}, command #{matchedRule.Command}, #{matchedRule.RuleCommandDescription}.")
   case matchedRule.Command
      when "Dial"
         sys.Dial(matchedRule.CommandParameter1 + "@" + matchedRule.CommandParameter2)
      when "DialAdvanced"
          ringTime = matchedRule.CommandParameter2 != nil ? matchedRule.CommandParameter2.to_i : 0
         callDuration = matchedRule.CommandParameter3 != nil ? matchedRule.CommandParameter3.to_i : 0
         sys.Dial(matchedRule.CommandParameter1, ringTime, callDuration)
      when "Reject"
         sys.Respond(matchedRule.CommandParameter1.to_i, matchedRule.CommandParameter2)
      else
         sys.Log("Error command #{matchedRule.Command} not recognised.")
   end
end

sys.Log("SimpleWizard processing commenced.")
if sys.Out
   rules = lookup.GetSimpleWizardRules(sys.DialPlanName, "Out")
   rules.each{|rule|
      #sys.Log("#{rule.Pattern} #{rule.Command} #{rule.RuleCommandDescription}")
      if rule.PatternType == "Exact" && rule.Pattern == req.URI.User
         ProcessMatch(rule)
      elsif rule.PatternType == "Prefix"
          prefixPattern = "^" + rule.Pattern.TrimStart('_')
         prefixPattern = prefixPattern.sub("X", "[0-9]")
         prefixPattern = prefixPattern.sub("Z", "[1-9]")
         prefixPattern = prefixPattern.sub("N", "[2-9]")
         prefixPattern = prefixPattern.sub("*", "\*")
         prefixPattern = prefixPattern.sub("+", "\+")
          if req.URI.User =~ /#{prefixPattern}/
           ProcessMatch(rule)
         end
      elsif rule.PatternType == "Regex" && req.URI.User =~ /#{rule.Pattern}/
         ProcessMatch(rule)
      end
   }
else
   sys.Log("Incoming rule, FromName=#{req.Header.From.FromName}, FromURI=#{req.Header.From.FromURI.ToParameterlessString()}.")
   rules = lookup.GetSimpleWizardRules(sys.DialPlanName, "In")
   rules.each{|rule|
      #sys.Log("#{rule.Pattern} #{rule.Command} #{rule.RuleCommandDescription}")
      if ((rule.ToSIPAccount == nil || rule.ToSIPAccount == (req.URI.User + "@" + sys.GetCanonicalDomain(req.URI.Host)) ||
            rule.ToSIPAccount == (req.URI.User.sub(/^.*\./, "") + "@" + sys.GetCanonicalDomain(req.URI.Host))) &&
         (rule.TimePattern == nil || rule.IsTimeMatch(System::DateTimeOffset.UtcNow, sys.GetTimezone)) &&
         (rule.Pattern == nil || req.Header.From.FromName =~ /#{rule.Pattern}/ || req.Header.From.FromURI.ToParameterlessString() =~ /#{rule.Pattern}/)) then
           ProcessMatch(rule)
          break
      end
   }
end

raj2ras
Posts: 132
Joined: Tue Nov 08, 2011 2:13 am

Re: Renaming / Duplicating the wizard dial plans

Postby raj2ras » Mon Dec 12, 2011 2:04 am

Hmmm... Too complex for my simple needs :shock: , but thanks for sharing. Some day I may be able to comprehend!


Return to “Dial Plan Wizards (Telis & Simple)”

Who is online

Users browsing this forum: No registered users and 1 guest