The one method that matters
GmailThread has a method called createDraftReply. It takes a plain-text body string, sets the To address to whoever sent the last message in the thread, prefixes the subject with 'Re:' if it isn't already there, and inserts the draft into the same thread. The draft appears in Gmail exactly as if you had clicked Reply and then saved.
The alternative most people reach for first is GmailApp.createDraft. That method creates a standalone draft with no thread association. When you send it, Gmail treats it as a new conversation. The recipient sees a fresh subject line, their mail client doesn't group it with the original, and your Sent folder splits the history. I have watched this bite people who built automated follow-up tools and only noticed the problem weeks later when a client asked why they were getting duplicate threads.
The fix is always the same: get the GmailThread object first, then call createDraftReply on it, not on GmailApp.