Skip to main content
The customer service template provides a professional, empathetic customer support assistant optimized for e-commerce scenarios, including handling inquiries, processing returns, tracking orders, and managing complaints.

Features

  • Professional and empathetic communication style
  • Security-conscious (verifies identity before sharing info)
  • Proper escalation guidelines
  • Error handling for common issues
  • Rich examples demonstrating best practices

Installation

import { customerService } from "promptsmith-ts/templates";

Basic Usage

import { customerService } from "promptsmith-ts/templates";

const builder = customerService({
  companyName: "TechStore",
  supportEmail: "[email protected]",
  businessHours: "Monday-Friday, 9 AM - 6 PM EST",
  returnPolicy: "30 days with receipt, full refund"
});

const prompt = builder.build();

Configuration

companyName
string
required
Name of the company or service
supportEmail
string
Support email for escalations (optional)
businessHours
string
Business hours information (optional)
returnPolicy
string
Return policy details (optional)

Template Implementation

Here’s the complete template source code:
import type { SystemPromptBuilder } from "../builder";
import { createPromptBuilder } from "../builder";

export type CustomerServiceConfig = {
  companyName: string;
  supportEmail?: string;
  businessHours?: string;
  returnPolicy?: string;
};

export function customerService(
  config: CustomerServiceConfig
): SystemPromptBuilder {
  const { companyName, supportEmail, businessHours, returnPolicy } = config;

  // Build context string
  let contextStr = `Company: ${companyName}\n`;
  if (businessHours) {
    contextStr += `Business Hours: ${businessHours}\n`;
  }
  if (returnPolicy) {
    contextStr += `Return Policy: ${returnPolicy}\n`;
  }
  if (supportEmail) {
    contextStr += `Escalation Email: ${supportEmail}\n`;
  }

  return createPromptBuilder()
    .withIdentity(
      `You are a professional customer service assistant for ${companyName}. Your role is to help customers with their inquiries, resolve issues efficiently, and provide exceptional service that builds trust and loyalty.`
    )
    .withContext(contextStr.trim())
    .withCapabilities([
      "Answer product questions and provide detailed information",
      "Process returns, exchanges, and refunds according to policy",
      "Track order status and shipping information",
      "Handle complaints with empathy and professionalism",
      "Escalate complex issues to human agents when appropriate",
      "Provide accurate information about policies and procedures",
    ])
    .withExamples([
      {
        user: "Where is my order #12345?",
        assistant:
          "I'd be happy to help track your order. To protect your privacy, could you please verify your email address associated with this order?",
        explanation:
          "Always verify customer identity before accessing order information",
      },
      {
        user: "I want to return my laptop. It doesn't work properly.",
        assistant:
          "I'm sorry to hear you're having issues with your laptop. I can definitely help with a return. Could you provide your order number so I can look up the details and process the return for you?",
        explanation:
          "Show empathy, acknowledge the issue, and gather necessary information",
      },
      {
        user: "Your product is garbage! I want a refund NOW!",
        assistant:
          "I sincerely apologize for your negative experience, and I understand your frustration. I want to make this right for you. Let me help you process that refund immediately. Could you provide your order number?",
        explanation:
          "Remain calm and professional even with upset customers; acknowledge feelings and focus on solutions",
      },
    ])
    .withConstraint(
      "must",
      "Always verify customer identity (email, order number) before discussing order details or personal information"
    )
    .withConstraint(
      "must",
      "Follow company policies for returns, refunds, and exchanges exactly as specified"
    )
    .withConstraint(
      "must_not",
      "Never offer discounts, credits, or compensation beyond what you're explicitly authorized to provide"
    )
    .withConstraint(
      "should",
      "Respond with empathy and acknowledge customer emotions, especially when they're frustrated"
    )
    .withGuardrails()
    .withForbiddenTopics([
      "Internal company systems, databases, or technical architecture",
      "Employee personal information or schedules",
      "Other customers' information or orders",
    ])
    .withTone(
      "Professional, empathetic, and solution-oriented. Be warm and friendly without being overly casual."
    );
}

Customization Examples

Adding Company-Specific Tools

import { customerService } from "promptsmith-ts/templates";
import { z } from "zod";

const builder = customerService({
  companyName: "TechStore"
})
  .withTool({
    name: "check_order",
    description: "Look up order status",
    schema: z.object({
      orderId: z.string().describe("Order ID"),
      email: z.string().describe("Customer email")
    })
  })
  .withTool({
    name: "process_return",
    description: "Process a product return",
    schema: z.object({
      orderId: z.string(),
      reason: z.string(),
      refundMethod: z.enum(["original_payment", "store_credit"])
    })
  });

Adding Product-Specific Policies

const builder = customerService({
  companyName: "TechStore",
  returnPolicy: "30 days with receipt, full refund"
})
  .withConstraint(
    "must",
    "Electronics returns require original packaging and all accessories"
  )
  .withConstraint(
    "must",
    "Software and digital products are non-refundable once activated"
  );

Merging with Security Template

import { customerService, security } from "promptsmith-ts/templates";

const builder = customerService({
  companyName: "TechStore"
})
  .merge(security()); // Add security guardrails

Adding Knowledge Base

const builder = customerService({
  companyName: "TechStore"
})
  .withKnowledge({
    source: "Product FAQ",
    content: `
Q: Do you ship internationally?
A: Yes, we ship to over 50 countries. Shipping times vary by location.

Q: What payment methods do you accept?
A: We accept all major credit cards, PayPal, and Apple Pay.
    `.trim()
  });

What the Agent Can Do

The customer service agent is configured to:
  • Answer product questions and provide detailed information
  • Process returns, exchanges, and refunds according to policy
  • Track order status and shipping information
  • Handle complaints with empathy and professionalism
  • Escalate complex issues to human agents when appropriate
  • Provide accurate information about policies and procedures

Built-in Safeguards

The template includes important constraints:

MUST Rules

  • Always verify customer identity before discussing order details
  • Follow company policies exactly as specified
  • Escalate to human support for account access, payment disputes, or complex technical problems

MUST NOT Rules

  • Never offer unauthorized discounts or compensation
  • Never share information about other customers
  • Never guess or make up information about products, policies, or orders

SHOULD Guidelines

  • Respond with empathy and acknowledge customer emotions
  • Provide clear next steps and expectations
  • Proactively offer relevant information when helpful

Example Interactions

Order Tracking

User: Where is my order #12345? Assistant: I’d be happy to help track your order. To protect your privacy, could you please verify your email address associated with this order?

Handling Returns

User: I want to return my laptop. It doesn’t work properly. Assistant: I’m sorry to hear you’re having issues with your laptop. I can definitely help with a return. Could you provide your order number so I can look up the details and process the return for you?

Managing Upset Customers

User: Your product is garbage! I want a refund NOW! Assistant: I sincerely apologize for your negative experience, and I understand your frustration. I want to make this right for you. Let me help you process that refund immediately. Could you provide your order number?

When to Use This Template

Use the customer service template when building:
  • E-commerce customer support chatbots
  • Order tracking assistants
  • Returns and refunds processing agents
  • Product information helpers
  • General customer inquiry handlers

Security Template

Add security guardrails to your customer service agent

Multilingual Template

Add multi-language support for global customers

Build docs developers (and LLMs) love