Ai knowledge and logicHelpers

shopify_get_customer

Look up a Shopify customer by email address.

shopify_get_customer(context: dict, email: str) -> dict | None

Retrieves a Shopify customer profile by email address. Returns None if no customer is found.

Requires the Shopify integration to be installed for the business.


Parameters

NameTypeDescription
contextdictThe context object passed to your action
emailstrThe customer's email address

Returns

dict | None — Customer data including id, email, firstName, lastName, phone, createdAt, and updatedAt. Returns None if the customer is not found.


Examples

Greet a returning customer by name

def execute_action(context):
    email = context["args"]["email"]
    customer = shopify_get_customer(context, email)

    if customer is None:
        return {"found": False}

    return {
        "found": True,
        "firstName": customer["firstName"],
        "lastName": customer["lastName"],
        "customerSince": customer["createdAt"],
    }

Check if a customer exists before processing a request

def execute_action(context):
    email = context["args"]["email"]
    customer = shopify_get_customer(context, email)

    if customer is None:
        return {"error": "No account found for this email address."}

    # Proceed with customer-specific logic
    return {"customerId": customer["id"], "email": customer["email"]}

On this page