{
	"sip_agent": {
	"listen_net": "tcp",				// network to listen on <udp|tcp|tcp-tls>
	"request_processors": [
			{
				"id": "Register",
				"filters": ["*notstring:~*vars.Method:INVITE"],
				"flags": ["*none"],
				"request_fields":[],
				"reply_fields":[
					{"tag": "Request", "path": "*rep.Request", "type": "*constant",
						"value": "SIP/2.0 405 Method Not Allowed"}
				]
			},
			{
				"id": "RoutesQuery", 
				"filters": ["*string:~*vars.Method:INVITE"],
				"flags": ["*event","*chargers", "*routes", "*attributes:*derived_reply","*continue"],
				"request_fields":[
					{"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
						"value": "~*req.From{*sipuri_user}", "mandatory": true},
					{"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable",
						"value": "~*req.To{*sipuri_user}", "mandatory": true},
					{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
						"value": "*now", "mandatory": true},
					{"tag": "Category", "path": "*cgreq.Category", "type": "*variable",
						"value": "call", "mandatory": true},
				],
				"reply_fields":[
				]
			},
			{
				"id": "RoutesQueryOneRoute",
				"filters": ["*string:~*vars.Method:INVITE",
					"*gte:~*cgrep.RouteProfiles[*raw].Length:1",
					"*gte:~*cgrep.RouteProfiles[*raw][0].Routes.Length:1",
				],
				"flags": ["*none","*continue"], // do not send request to CGRateS
				"reply_fields":[
					{"tag": "Request", "path": "*rep.Request", "type": "*constant",
						"value": "SIP/2.0 302 Moved Temporarily"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"\""},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"~*req.To{*sipuri_user}"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"\" <sip:"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"~*req.To{*sipuri_user}"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"@"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
						"value": "~*cgrep.RouteProfiles[*raw][0].Routes[0].RouteParameters"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"`>;q=0.7; expires=3600;cgr_cost=`"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
						"value":"~*cgrep.RouteProfiles[*raw][0].Routes[0].SortingData.Cost"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"`;cgr_maxusage=`"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
						"value":"~*cgrep.RouteProfiles[*raw][0].Routes[0].SortingData.MaxUsage"},
					{"tag": "P-Charge-Info", "path": "*rep.P-Charge-Info", "type": "*composed",
                  		"filters": ["*notempty:~*cgrep.Attributes[<~*cgrep.RouteProfiles[*raw][0].Routes[0].RouteID>].P-Charge-Info:"],
						"value": "~*cgrep.Attributes[<~*cgrep.RouteProfiles[*raw][0].Routes[0].RouteID>].P-Charge-Info"},
				]
			},
			{
				"id": "RoutesQueryTwoRoutes",
				"filters": ["*string:~*vars.Method:INVITE",
					"*gte:~*cgrep.RouteProfiles[*raw].Length:1",
					"*gte:~*cgrep.RouteProfiles[*raw][0].Routes.Length:2",
				],
				"flags": ["*none","*continue"],
				"reply_fields":[
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":",\""},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"~*req.To{*sipuri_user}"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"\" <sip:"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"~*req.To{*sipuri_user}"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"@"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
						"value": "~*cgrep.RouteProfiles[*raw][0].Routes[1].RouteParameters"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"`>;q=0.2;cgr_cost=`"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"~*cgrep.RouteProfiles[*raw][0].Routes[1].SortingData.Cost"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"`;cgr_maxusage=`"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"~*cgrep.RouteProfiles[*raw][0].Routes[1].SortingData.MaxUsage"}
				]
			},
			{
				"id": "RoutesQueryThreeRoutes",
				"filters": ["*string:~*vars.Method:INVITE",
					"*gte:~*cgrep.RouteProfiles[*raw].Length:1",
					"*gte:~*cgrep.RouteProfiles[*raw][0].Routes.Length:3",
				],
				"flags": ["*none","*continue"],
				"reply_fields":[
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":",\""},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"~*req.To{*sipuri_user}"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"\" <sip:"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"~*req.To{*sipuri_user}"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"@"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value": "~*cgrep.RouteProfiles[*raw][0].Routes[2].RouteParameters"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"`>;q=0.1;cgr_cost=`"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"~*cgrep.RouteProfiles[*raw][0].Routes[2].SortingData.Cost"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"`;cgr_maxusage=`"},
					{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
							"value":"~*cgrep.RouteProfiles[*raw][0].Routes[2].SortingData.MaxUsage"}
				]
			}
		]
	}

}
