Build a ready-to-deploy agent to transform text into structured in minutes
Build one AI agent that is able to list all the files on Google Drive, find the appropriate Google Docs template for a given input message, and reformat the input message according to the template in the document.Once you’ve entered the prompt, click the “Build AI Agent” button. In just a few seconds, the Planner will generate the agent for you. In the end, you should see a ready-to-run AI agent represented in a graph similar to the following:
Message: “David will have a business meeting with the marketing team at 10:30 AM on April 12, 2025, at the main meeting room in the office. The meeting is expected to last 2 hours.” Can you reformat the message above according to the template in the ‘Meeting Schedule Summary’ document? Please write the reformatted text here, but don’t write the output in a new Google Docs.And the Google Docs template we’re working with (stored on Google Drive) looks like this:
Message: “David will have a business meeting with the marketing team at 10:30 AM on April 12, 2025, at the main meeting room in the office. The meeting is expected to last 2 hours.” Can you reformat the message above according to the template in the ‘Meeting Schedule Summary’ document? Please send the reformatted message to myemail@zohomail.eu and write the reformatted text here as well.As you can see in the image below, after reformatting the message using the “Retrieve Latest Document Version” operation, the agent now uses the newly added “Send Email with Content” operation to send the result to the specified email address.
xpander
library along with any required dependencies using pip
. Since we’re using OpenAI’s GPT-4o as the agent’s model, we’ll also need to install the openai
library.
.env
file and load it with the dotenv
library, or just assign them directly as variables if you’re using the code privately. Below is an example of how you can initialize the interaction with the agent.
XpanderMessagingServiceSendEmailWithContent
)add_task()
method, passing in our input prompt as the argument.
GoogleFileManagementListUserFiles
tool to list all files on Google Drive and find the ID of the Google Docs we’re looking for. You can also see the query or input arguments provided by the agent to call the corresponding tool.
Next, we’ll add the agent’s response to memory, call the GoogleFileManagementListUserFiles
tool with xpander, and run it using the input arguments provided in the agent’s response.
GoogleDocsDocMgmtRetrieveLatestDocumentVersion
tool, which retrieves the content of the document we’re looking for.
Just like before, we’ll add the agent response to the memory, call the corresponding tool, and run it to get its response.
xpfinish-agent-execution-finished
to signal that it has everything it needs to complete the task. As usual, we just need to add the agent response to the memory, call the tool, and run it to get the response.
while
loop. This way, we keep executing the agent until the is_finished
method returns True
.
Here’s the final, simplified workflow using a while
loop: