Take a look to the parameter's placeholder syntax:
https://www.seektable.com/help/mongodb-pivot-table#parametersYou can specify part of JSON inside in this way:
{$and: [
@senderRole[ {{ "senderRole":{0} }}, ]
{"senderId":@ssdsid}
]}
if 'senderRole' is not defined it is just not included into the filter JSON. Note that inside @senderRole[ ] "{{" should be used instead of "{" because these special chars are used to specify parameter's value with {0}.
In similar way you can use "$in" to apply a multi-value parameter:
{$and: [
@senderRole[ {{ "senderRole": {{ "$in" : {0} }} }}, ]
{"senderId":@ssdsid}
]}