Change the message argument so it returns the atom

deleted because solution to be done

What exactly are you trying to achieve here? Your question is very specific and none of us is working on your project. Give some more details, plus why is the type of this field even important?

The scheduled_ function you posted should, when called with Factory.scheduled_(:insufficient), return a map with the expected message:

      "event_type" => "scheduled",
      "attributes" => %{
        "error_reason" => 
          "message" => :insufficient

You can verify this by adding |> IO.inspect() onto the line where scheduled_ is called:

mail_case = %MailScenario{
      event_type: "scheduled",
      event: Factory.scheduled_(:insufficient) |> IO.inspect(),

The second part of your question is labeled “return in console”, but this has the attributes key displayed like an atom (attributes:); can you explain more about how that value is produced?

Closed on request of the OP.