# Role Instruction Design Guide

{% hint style="info" %}
You can use the [AI tool for generating system prompts](https://chat.maiagent.ai/web-chats/4b67b140-db5f-40dc-bce3-f2217e9574bd) created by MaiAgent to help you refine your system prompts
{% endhint %}

## 🎭 What is a "System Prompt"?

Imagine you're directing a movie and need to tell actors what role they're playing, their personality traits, and how they should speak. A **system prompt** is like a "script" for AI, telling it what kind of customer service representative to play.

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-37ae97af9a95ef0fa6cfe0ee8986844fc0ba233a%2F636b6ac8-d482-4a72-99ce-c3764441c2e9.jpg?alt=media" alt=""><figcaption></figcaption></figure>

### 📚 Technical Terms Glossary

Before we begin, let's familiarize ourselves with some important concepts:

**🤖 AI Agent**

* **Analogy**: Like a virtual employee you hire
* **Explanation**: An AI system capable of autonomously executing tasks; in customer service scenarios, it's your digital customer service representative

**💬 Prompt**

* **Analogy**: A "job description" for AI
* **Explanation**: Instruction text that tells AI what to do and how to do it

**🎯 Context**

* **Analogy**: The "memory" and "background information" of a conversation
* **Explanation**: Relevant information needed for AI to understand the current conversation situation

**🔄 Token**

* **Analogy**: The "unit" AI uses to understand text, like breaking sentences into small pieces
* **Explanation**: The basic unit when AI processes text, affecting processing efficiency and cost

***

## 🌟 Why Are System Prompts So Important?

#### AI Customer Service Without System Prompts 😵

```
User: "Where is my order?"
AI: "According to system data, your order status is processing."
```

*Feels like talking to a robot, cold and impersonal*

#### AI Customer Service With Good System Prompts 😊

```
User: "Where is my order?"
AI: "I completely understand your concern! Let me check your order status right away.
     According to tracking information, your package is currently at the distribution center
     and is expected to arrive tomorrow afternoon. Would you like me to provide the tracking number?"
```

*Feels like talking to a real customer service agent, warm and professional*

***

## 🏗️ The Four Pillars of System Prompts

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-ede1fe891c61968c4a59f762a85401ab7a5661e8%2F7c0349c3-94f0-4644-ba55-c7313a35dad2%20(1)%20(1)%20(1).jpg?alt=media" alt=""><figcaption></figcaption></figure>

#### 1. 🎭 Identity Positioning (Who)

Tell the AI "who you are"

**❌ Vague Identity**

```
You are a customer service agent
```

**✅ Clear Identity**

```
You are "Xiaomei," a senior customer service representative at MaiAgent,
with 5 years of customer service experience, specializing in product consultation and problem-solving.
```

#### 2. 🗣️ Tone and Style (How)

Tell the AI "how to speak"

**Tone Selection Guide:**

* **Professional and Formal**: Suitable for finance, legal, medical industries
* **Friendly and Approachable**: Suitable for retail, food service, lifestyle services
* **Lively and Young**: Suitable for gaming, entertainment, fashion industries
* **Warm and Caring**: Suitable for education, health, social services

**Example: Friendly and Approachable Style**

```
Please use a warm, friendly tone in responses.
Use "you" appropriately to show respect.
Include friendly phrases like "Happy to help you,"
but avoid excessive enthusiasm or too many exclamation marks.
```

#### 3. 🎯 Professional Capabilities (What)

Tell the AI "what you can do"

```
Your professional capabilities include:
- Product feature introduction and usage guidance
- Order inquiry and logistics tracking
- Return and exchange policy explanation
- Preliminary technical issue diagnosis
- Account and payment issue handling

When encountering issues beyond your capabilities,
proactively transfer to human customer service.
```

#### 4. 📋 Behavioral Guidelines (Rules)

Tell the AI "what can and cannot be done"

```
Principles to follow:
✅ Protect user privacy, do not disclose personal information
✅ Admit when you don't know something, don't fabricate answers
✅ Stay calm when handling complaints, apologize first then solve
✅ Keep responses under 100 words, maintain brevity

Absolutely prohibited:
❌ Making promises that cannot be fulfilled
❌ Arguing or contradicting users
❌ Disclosing company internal information
❌ Processing refund requests beyond authority
```

***

## 🛠️ Hands-On: Designing Your First System Prompt

#### Step 1: Analyze Your Business Needs

**Consider these questions:**

* Who are your customers? (age, occupation, usage habits)
* What are your product/service features?
* What questions do customers ask most frequently?
* What kind of service experience do you want to provide customers?

#### Step 2: Choose Appropriate Role Settings

**🏪 E-commerce Customer Service Example**

```
You are "Little Helper," a professional online shopping consultant.
You are familiar with all product information, excel at recommending suitable products,
and can quickly handle order-related issues.
Your speaking style is friendly and natural, caring about customer needs like a friend.
```

**🏥 Medical Customer Service Example**

```
You are "Health Helper," a professional medical service consultant.
You have basic medical knowledge and can provide information on appointments, examination procedures, etc.,
but you never provide medical diagnostic advice.
Your speaking style is professionally warm, making patients feel reassured.
```

#### Step 3: Write Complete System Prompts

**📝 System Prompt Template**

```
# Role Identity
You are [role name], a [position] at [company name].
[Role background and professional experience]

# Service Goals
Your main task is [core task],
helping customers [achieve goals] through [service methods].

# Language Style
- Tone: [choose appropriate tone]
- Word Choice: [specific word choice requirements]
- Length: [response length limit]

# Professional Capabilities
You can handle the following issues:
- [Capability 1]
- [Capability 2]
- [Capability 3]

# Behavioral Guidelines
Must follow:
✅ [Guideline 1]
✅ [Guideline 2]

Absolutely prohibited:
❌ [Prohibition 1]
❌ [Prohibition 2]

# Special Situation Handling
When encountering [special situations], please [handling method].
```

***

## 🎨 Advanced Techniques: Making Your System Prompts More Vivid

#### 1. 🎪 Add Personality Traits

**Regular Version:**

```
You are a customer service agent responsible for answering questions.
```

**Vivid Version:**

```
You are "Xiaozhi," a curious tech enthusiast.
You're always excited about new features and love using simple analogies
to explain complex technical concepts, making them easy for everyone to understand.
```

#### 2. 🎯 Contextualized Instructions

Adjust response methods based on different contexts:

```
# Context-Aware Instructions
- When customers express dissatisfaction: Respond with empathy first, then provide solutions
- When customers ask technical questions: Explain using everyday analogies
- When customers hesitate about purchases: Provide objective advice, don't force sales
- When customers praise products: Express gratitude and ask if other assistance is needed
```

#### 3. 🔄 Dynamic Adjustment Mechanism

```
# Conversational Adaptability
Adjust your style based on customer responses:
- If customers use formal language, be relatively formal
- If customers are impatient, be more concise and efficient
- If customers are chatty, you can extend the topic slightly
```

#### **4. Version Control Friendly**

* Add version numbers and update logs
* Maintain backward compatibility, ensuring existing processes continue to work correctly after system prompt updates

Example:

```
Version: v1.0
# Update Date: October 26, 2024
# Update Log:
#   - Initial version, provides basic product recommendation functionality.
#   - Recommends products based on user preferences.
#   - Response tone set to friendly and professional.
```

***

## 🚀 Testing and Optimizing Your System Prompts

#### Phase 1: Basic Testing

Test whether AI responses meet expectations with common questions

**Test Question Examples:**

* "What is your return policy?"
* "When will my order arrive?"
* "Is this product suitable for me?"

#### Phase 2: Boundary Testing

Test AI performance in extreme situations

**Boundary Situation Examples:**

* When customers are emotionally agitated
* When encountering questions with unknown answers
* When asked to do things beyond authority

#### Phase 3: Continuous Optimization

**📊 Collect Data**

* Customer satisfaction ratings
* Problem resolution rate
* Human transfer rate

**🔧 Adjustment Strategy**

* Supplement knowledge base based on common questions
* Adjust language style based on customer feedback
* Improve behavioral guidelines based on failure cases

***

## **📝 System Prompt Length Control Techniques**

**Best Practice Guidelines**

The ideal length for system prompts should be controlled within 500-2000 words (approximately 200-800 tokens), with common optimal values ranging from 800-1500 words.

Remember this core principle: "Clarity over verbosity" — overly long instructions are easily ignored by models, while too short may lead to unstable behavior.

**Why Does Length Matter?**

First is model performance consideration: excessively long prompts distract model attention and affect execution of key instructions. Second is context space limitation: system prompts occupy the conversation's context window, compressing user dialogue space. Finally is maintenance cost: concise, structured prompts are easier to continuously optimize and adjust.

**Three Writing Techniques**

Structured Design: Clear segmentation with core instructions placed at the front.

Simplification Principle: Remove repetitive descriptions and lengthy backgrounds, keeping only necessary rules.

Continuous Validation: Conduct A/B testing for different models (GPT, Claude, Gemini) to find optimal length configuration.

**Practical Considerations**

Different AI models have varying tolerance for long prompts and require individual testing and validation. In token calculation, Chinese is approximately 1 character per token, while English is approximately 1 token per 0.75 words. Since system prompts have higher instruction weight, it's recommended to keep content focused and avoid unnecessary verbose descriptions.

***

## 💡 Common Questions and Solutions

#### Q1: How to make AI responses more natural?

**A:** Add specific conversation examples to system prompts and set clear language style guidance.

#### Q2: What if AI always answers irrelevant questions?

**A:** Clearly define service scope in system prompts and teach AI how to identify and handle out-of-scope questions.

#### Q3: How to balance professionalism and approachability?

**A:** Adjust according to your target customer group. B2B customers prefer professionalism, B2C customers prefer approachability. Design A/B tests to find the optimal balance.

***

## 🎉 Conclusion: Creating Your Exclusive AI Customer Service

Designing system prompts is like training a new employee, requiring patience and continuous adjustment. Remember these key principles:

1. **🎯 Clear Positioning**: Clearly tell AI who it is
2. **🗣️ Style Consistency**: Maintain unified language style
3. **📋 Clear Boundaries**: Clearly define what can and cannot be done
4. **🔄 Continuous Optimization**: Constantly improve based on actual usage

Start designing your first system prompt now! Remember, the best system prompts are continuously refined through actual use.
