AST_SORCERY gets a field from a sorcery object. Sorcery is always created for PJSIP aors, endpoints and identifies in asterisk. It allows you to access information from dialplan in runtime.
AST_SORCERY(module_name,object_type,object_id,field_name[,retrieval_method[,retrieval_details]])
PJSIP config example:
[mytrunk]
type=aor
contact=sip:sip.example.com:5060
[mytrunk]
type=endpoint
context=from-external
disallow=all
allow=ulaw,alaw,g722
outbound_auth=mytrunk
aors=mytrunk
[mytrunk]
type=identify
endpoint=mytrunk
match=sip.example.com
Usage example:
> dialplan eval function AST_SORCERY(res_pjsip,identify,mytrunk,match)
Return Value: Success (0)
Result: sip.example.com
> dialplan eval function AST_SORCERY(res_pjsip,endpoint,mytrunk,allow)
Return Value: Success (0)
Result: (ulaw|alaw|g722)
Enjoy!






