Yes, you may speak to your landlord before you go to court, however, unless the landlord files a motion to dismiss you will still have to appear in Court. If you do not appear in Court on the date, and the landlord does not seek to dismiss the action YOU WILL BE DEFAULTED.
I recommend speaking to the landlord to determine if a motion to dismiss is an option. If the landlord is not open to a dismissal, speak with a lawyer as soon as possible. Alternatively, you may go to the Clerk’s Office of the Housing Court (or District Court if outside of Boston) to determine how to file an answer. The Clerk’s Office has some very helpful forms for tenants to file an answer.
Best of luck.
See also Mass. General Laws chapter 186, §§ 11, 11A & 12, and the Mass. Trial Court Law Libraries' "Mass. Law About Landlord and Tenant," all linked below about your right to "cure" and the procedures for answering an eviction action in case your negotiations with your landlord do not pan out into his voluntarily dismissing the action against you.