Automated Email Correspondence

I have a use case I am looking to migrate off n8n into foundry. I want to automate email correspondence. In n8n, I have a gmail trigger monitoring incoming emails. Email comes in and is passed to LLM. LLM using gmail tool to send a reply.

I want to migrate to foundry to implement ontology context to the LLM such that an email comes in, AIP logic can query ontology, and we email back a response. Will I have to use workflow builder? I set up an OSDK to potentially do off platform but I would like to do fully in platform if possible. Thanks in advance for any tips.

ive set up an osdk for my ontology and built a backend service that remains idle for emails coming through then when an email matches criteria, we route the contents of the message to the AIP logic I created which then returns the response to the backend which will then send an email using this response.