Skip to main content
Agents

Extract full name and email

Written By William Bowen

Last updated Over 1 year ago

Intro

This AI agent on Clerk Chat automatically checks each contact card for a full name and email address whenever a contact messages in. If any details are missing, it intelligently scans the conversation history to extract them and creates a new contact or asks the user for these details if necessary.

For example, if a user types "Hi, I'm Jane Doe and my email is jane@example.com," the agent will update the contact card with that information before moving on to its next task.

Use cases

New Contact Initialization – The AI agent auto-generates a contact entry from a user's message by extracting the name and email if the contact card is empty. For example, when someone writes, "Hi, I'm John Smith, my email is john.smith@example.com," the agent creates a new contact with that information.

Data Recovery from Incomplete Profiles – It identifies missing contact details by reviewing previous conversation history to fill gaps in the contact card. For example, if a contact card only has an email but no name, and the chat includes "This is Sarah Connor," the agent adds the name accordingly.

Error Handling in Contact Creation – The agent detects inconsistencies or missing data in a contact card and prompts the user for clarification. For instance, if a conversation only includes "email: mike@example.com" without a name, the AI asks, "Could you please provide your full name?"

Automated Follow-Up – Once the contact is fully populated, the agent immediately moves to the next logical step in the workflow. For example, after confirming "Emily Rose" and "emily.rose@example.com," it asks, "What service are you interested in today?"

CRM Data Integrity – It ensures every new conversation has complete and accurate data in the CRM, improving overall data quality. For example, during a multi-channel chat session, the agent confirms and updates the contact details for every message thread.

Pre-Screening for Customer Support – The agent quickly gathers essential contact information before routing to a human agent. For example, in a support chat, it ensures the contact card includes "Alex Turner" and "alex.turner@example.com" before transferring the chat.

Personalized User Engagement – It uses the contact’s name to create a personalized conversation experience. For example, once it confirms "Olivia Brown," the follow-up message might read, "Hi Olivia, how can I assist you today?"

Multi-Channel Consistency – The agent consolidates data across various messaging channels to maintain a single, unified contact profile. For example, if a user sends an email and a chat message from the same person, the agent ensures both interactions are recorded under one complete contact profile.

Marketing List Enrichment – Complete contact details enable effective segmentation and targeted marketing campaigns. For example, after verifying "Liam Davis" and "liam.davis@example.com," the agent flags the contact for a promotional email campaign.

Pre-Call Preparation – The agent’s collection of full contact information helps sales teams prepare for calls with a detailed profile. For example, before a scheduled call, the system shows the representative that the contact is "Sophia Miller" with "sophia.miller@example.com," ensuring a smoother engagement.

Screenshots

Template

{
  "$schema": "https://web-api.clerk.chat/pipeline-schema",
  "name": "Email and name",
  "nodes": [
    {
      "type": "ai_bot",
      "name": "Ask appropriate next question",
      "triggeredBy": [
        "unreadMessage.fromAny"
      ],
      "responseType": "user_message",
      "nodeConfig": {
        "modelProvider": "openai",
        "modelVersion": null,
        "maxTokens": null,
        "temperature": null,
        "variables": {},
        "prompt": "Your job is to read the conversation history and ask a suitable next question to the lead. It should be conversational and related to the lead's incoming message. \n\nYour output should be less than 30 words.",
        "promptSections": [],
        "sectionTemplates": {},
        "responseSchema": {
          "type": "object",
          "required": [],
          "properties": {}
        },
        "opts": {
          "sendStructuredConvo": true
        }
      }
    },
    {
      "type": "tool_runner",
      "name": "Set email",
      "triggeredBy": [
        "unreadMessage.fromAny"
      ],
      "responseType": "json",
      "nodeConfig": {
        "type": "contact_tools",
        "config": {},
        "enabledTools": [
          "set_attribute"
        ],
        "tools": {
          "set_attribute": {
            "paramValues": {
              "attributeName": {
                "type": "fixed",
                "value": "email"
              },
              "attributeValue": {
                "path": "email",
                "type": "pipeline-variable"
              }
            }
          }
        }
      }
    },
    {
      "type": "tool_runner",
      "name": "Set name",
      "triggeredBy": [
        "unreadMessage.fromAny"
      ],
      "responseType": "json",
      "nodeConfig": {
        "type": "contact_tools",
        "config": {},
        "enabledTools": [
          "set_attribute"
        ],
        "tools": {
          "set_attribute": {
            "paramValues": {
              "attributeName": {
                "type": "fixed",
                "value": "name"
              },
              "attributeValue": {
                "path": "full_name",
                "type": "pipeline-variable"
              }
            }
          }
        }
      }
    },
    {
      "type": "ai_bot",
      "name": "Extract name + email",
      "triggeredBy": [
        "unreadMessage.fromAny"
      ],
      "responseType": "json",
      "nodeConfig": {
        "modelProvider": "openai",
        "modelVersion": null,
        "maxTokens": null,
        "temperature": null,
        "variables": {},
        "prompt": "Your job is to read the conversation history and extract the user's full name and email address. \n\nOutput their full name under: \"full_name\"\n\nOutput their email address under: \"email\"\n\nIf either of both of these are not present in the conversation, leave these variables plank (e.g. \"\").",
        "promptSections": [],
        "sectionTemplates": {},
        "responseSchema": {
          "type": "object",
          "required": [
            "email",
            "full_name"
          ],
          "properties": {
            "email": {
              "type": "string"
            },
            "full_name": {
              "type": "string"
            }
          }
        },
        "opts": {
          "sendStructuredConvo": true
        }
      }
    },
    {
      "type": "template",
      "name": "Ask for name and email",
      "triggeredBy": [
        "unreadMessage.fromAny"
      ],
      "responseType": "user_message",
      "nodeConfig": {
        "template": "Thanks for reaching out! To start, could I get your full name & email address?"
      }
    },
    {
      "type": "trigger",
      "name": "Start",
      "triggeredBy": [
        "userMessage"
      ],
      "responseType": "json"
    }
  ],
  "edges": [
    {
      "name": null,
      "sourceNode": "Set name",
      "destinationNode": "Set email",
      "sourceVariables": null,
      "filters": []
    },
    {
      "name": "If they are both filled",
      "sourceNode": "Set email",
      "destinationNode": "Ask appropriate next question",
      "sourceVariables": null,
      "filters": [
        {
          "type": "rule",
          "config": {
            "syntax": {
              "and": [
                {
                  "!": [
                    {
                      "isEmpty": [
                        {
                          "var": "context.full_name"
                        }
                      ]
                    }
                  ]
                },
                {
                  "!": [
                    {
                      "isEmpty": [
                        {
                          "var": "context.email"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          }
        }
      ]
    },
    {
      "name": null,
      "sourceNode": "Extract name + email",
      "destinationNode": "Set name",
      "sourceVariables": null,
      "filters": []
    },
    {
      "name": "If either is still empty",
      "sourceNode": "Set email",
      "destinationNode": "Ask for name and email",
      "sourceVariables": null,
      "filters": [
        {
          "type": "rule",
          "config": {
            "syntax": {
              "or": [
                {
                  "isEmpty": [
                    {
                      "var": "context.full_name"
                    }
                  ]
                },
                {
                  "isEmpty": [
                    {
                      "var": "context.email"
                    }
                  ]
                }
              ]
            }
          }
        }
      ]
    },
    {
      "name": "If name or email are empty",
      "sourceNode": "Start",
      "destinationNode": "Extract name + email",
      "sourceVariables": null,
      "filters": [
        {
          "type": "rule",
          "config": {
            "syntax": {
              "or": [
                {
                  "isEmpty": [
                    {
                      "var": "context.contact.name"
                    }
                  ]
                },
                {
                  "isEmpty": [
                    {
                      "var": "context.contact.email"
                    }
                  ]
                }
              ]
            }
          }
        }
      ]
    }
  ]
}