You can’t. Pattern matches are meant to ensure the given data fulfills the pattern given. If you have optional data either use multiple patterns/functions or extract the data in the functions body using e.g. Map.get.
You can define a function that matches a map having both keys, and afterwards one that matches a partial map and calls the previous after putting defaults:
def foo(%{"param1" => param1, "param2" => param2}) do
end
def foo(params) when is_map(params) do
params
|> Map.put_new("param1", default_param1)
# as many as needed
|> foo()
end