Document Generation
The AI document generation system allows your agent to produce clean, crisp, nicely formatted documents and send them over to your end-user.
Template Editor
The first step in making your AI sales-bot is to create your document template. To do this, you need to access the Document Template
tab:
You should then get a view that looks like this:
This is the template editor. It is a full HTML and PDF page editor. To add new widgets into the page, press the “+” Icon:
You will then be presented with a menu with various options that you can drag into the editor.
If you select an element, such as this newly added 3-Column layout widget, the right side of the editor provides you with the full complement of attributes to edit the HTML of that widget:
Note that you need to be familiar with HTML CSS attributes in order to adjust the settings here.
Variable Bindings
A key aspect of the document generator is the ability to bind sections of the document to specific variables that an LLM model may have generated.
To do that, simply select a section that you would like to bind to a variable. Go to Properties, and type in the variable name you would like to bind to into the Variable Binding
box.
Note! It doesn’t really matter what text you put into the the editor itself. All text contained within the bound element gets replaced by the contents of the variable. In this example, we used [square_brackets]
as filler text for the document template. You could have also used filler text like an Lorem Ipsum
paragraph. It doesn’t matter - the text gets replaced by the contents of the bound variable.
Here is an example title page where we have made several bindings:
Template Settings
At the bottom of the screen provides us a second tab that we can flip to:
This allows us to set high level settings for this document template. It also provides fields for you to fill in values and see how the final rendered document looks.
Note! Its important to set a title for the document, or else the AI will not be able to choose it.
In order to test the rendering of the document, simply fill in values to these fields:
After we press submit on this example, and give it ten seconds or so to process, we see the final rendered result show up:
Bingo! We have a generated document.
Document Generation Smart Chain
If you go to the Settings tab, you will see that one of the settings is labelled the Smart Chain Binding:
This must point to a smart chain binding, which in turn points to a smart chain that will generate all of the required data for the document. The smart chain is triggered with a conversation object, and so can run Conversational Prompts as needed to generate the required information for the document.
You can define smart chain bindings here:
On this document template, I set a binding and pointed it to my smart chain to generate my proposal, which was also given the same name.
The smart chain itself can take practically any form you want. The only requirement is that the last step of the smart chain is where the data is pulled from to fill in the document. So it must have fields that match the same field names you put into the Variable Binding
setting.
In this example, we used a Structured Output Prompt in order to generate a Proposal object with a format that matches the input fields we defined in our variable bindings.
When an AI agent goes to try and generate this document, it will run this prompt, which produces these output fields, and then those get filled into the document template. You can see this in action by going to the “Web Chat” and talking to your agent, and requesting that it either email or generate you the document at the end.
Sometimes the main smart chain for your agent needs to be modified and explicitly prompted on when it is supposed to generate the document. This is particularly true if you are using the Intake module in combination with the Document Generation module.