The document generator feature comes in handy when you want to create Microsoft Word documents from a SharePoint list item. You might also encounter a scenario where you would like to generate a document and send it as an email attachment. Here's how to go about it:
Generate the document and save it in the library > Save the form > Send Email
For the attachment expression for the Send Email action, double-click "Url" under Generate Word Document in the Actions section.
This will generate the document, save it, and attach it to the email being sent.