Thanks for fitwxc's post. The out works, but the in does not work for me. After doing some search, I did some modification to the post and both in and out works. The change is to remove all the in related, add a check for sys.Out, do the out, else do the in. It is posted bellow.
Don't know why the original does not work. I also don't understand what this line mean
sys.Dial("VoipDiscount")
--------
#outbound call processing
if sys.Out
case req.URI.User
when /^1?\d\d\d\d\d\d\d\d\d\d$/ then
sys.Googl....
sys.Respond(480, "#{sys.Username} Not available")
when /^\+\d{3,}/,/^00\d{3,}/,/^011\d{3,}/ then
sys.Dial("VoipDiscount")
sys.Respond(480, "#{sys.Username} Not available")
else
sys.Respond(480, "#{sys.Username} Not available")
end
else # sys.Out
sys.Dial "#{sys.Username}@local"