The best advice I can give is to get an attorney. Since your question is very general, I can only give you general information. Restraining Order/Injunction cases are very fact based and really come down to whether your Judge feels that your boyfriend has a reasonable belief that you will do harm to him. Make sure you have thought through the events your boyfriend refers to in his petition so that you can communicate clearly to the court. If there are any witnesses, you should talk to them about testifying on your behalf.
Your boyfriend will get to tell his side first and you will get your turn to respond.
Dress appropriately. Behave appropriately. Do not make faces at your boyfriend. Do not make noises when/if he lies. Keep your composure. Be respectful to the Judge and all the courthouse staff.
Your best means of protecting your rights is by obtaining representation. Short of that, your boyfriend most likely must prove to the court that you either committed an act of domestic violence against him, or that he is in imminent danger of becoming the victim of domestic violence. Make sure to bring all witnesses and evidence to your hearing. Be aware that letters from witnesses are inadmissible and that all witnesses must present live testimony. If you have minor children involved, you may qualify for free representation through domestic violence programs in your state.
If you cant afford an attorney and are yourself a victim of domestic violence, I would suggest contacting legal aid.
Other then that, I agree completely with the first post. Also bring all witnesses with you, and if he says anything similar to "my friend told me . . ." say politely "objection, hearsay"