Automating Lead Inquiries

Hello, I want to automate lead inquiries.
Basically, I need to get the email body/context and parse the information to extract “name, email, phoneNumber, inquiry”. I extract this inside a OpenAI node.

Now, my question is, how can I parse the information from a JSON output to then 4 different outputs stating “name, email” etc…?
I did this inside the “code” node and it actually worked once, but then it just stopped working. It might be because the OpenAI node outputs different things all the time, for instance sometimes with \n and sometimes without newlines at all.

Please let me know if you understood! Thanks.

Hey ! To ensure a specific format, you can set an output parser to ensure a specific answer from your AI agent. It still can fail though, make sure your prompt is good for multiple cases and precise (you can put examples).

Here is the schema you can put in your output parser :

{
  "type": "object",
  "properties": {
    "name": {
      "type": ["string", "null"]
    },
    "email": {
      "type": ["string", "null"],
      "format": "email"
    },
    "phoneNumber": {
      "type": ["string", "null"]
    },
    "inquiry": {
      "type": ["string", "null"]
    }
  },
  "required": ["name", "email", "phoneNumber", "inquiry"]
}

Here all the fields are required and can be either something or null (you can change that and say in your prompt for example : "If the information is not here, put “not specified” instead of null)

Here is the simple workflow if you want to see my (very basic) prompt for this :

You can use information extraction node to extract these informations

1 Like