Prompt Engineering: From Generic Bot to Expert Agent

Welcome to our prompt engineering series! If you've ever built a bot and been disappointed by its vague, useless answers, this post is for you.

This is the first in a series of posts on advanced prompt engineering techniques. If you're new to prompt engineering, start with our fundamentals guide.

We've all seen this: you ask a specific question, and the AI gives you a generic, unhelpful script. This is the default "zero-shot" state of an LLM.

Today, we're going to build a Customer Support Bot, step-by-step, to see how we can transform it from a generic "helper" into a truly valuable expert by giving it a clear Goal, a defined Role, and real-time Context.

The problem: the "Have you tried...?" bot

Let's start with our "Problem": a basic, un-prompted bot. The user has a specific problem, and the bot gives a generic, unhelpful answer.

Use Case: The user's new laptop won't connect to Wi-Fi.

graph TD
A["User: 'My laptop won't connect to Wi-Fi. I've tried everything.'"] --> B(LLM)
B --> C["Bot: 'Oh no! I'm sorry to hear that. Have you tried turning it off and on again?'"]

style C fill:#ffebee,stroke:#b71c1c,color:#212121

Why this is bad:

It's not helpful. It ignores the "I've tried everything" context.

It doesn't gather any information.

It frustrates the user and wastes their time.

Improvement 1: Give the bot a goal (explicit instructions)

Instead of just "answering", let's give the bot a clear job: to gather information. This is our first technique: giving Explicit Instructions.

The "How": We'll use a System Prompt to define the bot's goal. A system prompt acts as a set of core, high-level instructions that the LLM must follow for the entire conversation.

# Our new "brain" for the bot
system_prompt = """
You are a support bot. Your ONLY goal is to gather information.

Do NOT try to solve the problem.

Ask 3-4 clarifying questions to understand the user's issue.
"""

user_query = "My laptop won't connect to Wi-Fi. I've tried everything."

Now, let's see how our bot behaves.

graph TD
subgraph BRAIN["The 'Brain' (System Prompt)"]
direction LR
A["Goal: Gather Info"]
B["Action: Ask 3-4 Questions"]
end

C["User: 'My laptop won't connect...'"] --> D(LLM)
BRAIN --> D

D --> E["Bot: Asks 3-4 clarifying questions about laptop model, OS, and network status"]

style E fill:#e8f5e9,stroke:#388e3c,color:#212121

Observation: This is much better. The bot is now a useful tool. It's following its instructions perfectly. But its tone is cold and robotic. We've defined what it should do, but not who it should be.

Think About It: Why is it better to instruct the bot not to solve the problem right away? What problems could happen if it tried to guess a solution too early?

Improvement 2: Give the bot a personality (role prompting)

Now let's fix the robotic tone. We can add a Role to our system prompt to make the bot empathetic and professional.

The "How": We'll update the system prompt to define a persona.

# We'll update our system prompt
system_prompt = """
You are "Alex", an empathetic Tier 1 support agent.

Your tone is friendly, professional, and apologetic.

Your ONLY goal is to gather information. Do NOT try to solve the problem.

Start by apologizing for the user's trouble, then ask 3-4 clarifying questions.
"""

Let's see the result of this change.

graph TD
subgraph BRAIN["The 'Brain' (System Prompt)"]
direction LR
A["Role: 'Alex' (Empathetic)"]
B["Goal: Gather Info"]
C["Action: Apologize, then ask"]
end

D["User: 'My laptop won't connect...'"] --> E(LLM)
BRAIN --> E

E --> F["Bot: Apologizes empathetically, then asks clarifying questions"]

style F fill:#e8f5e9,stroke:#388e3c,color:#212121

Observation: This is a huge leap. The user now feels heard. But the bot is still "dumb"—it's asking questions it should already know if it were part of a real application, like the user's name or device.

Improvement 3: Give the bot data (contextual prompting)

This is the final and most important step. We will inject real-time user data (Context) into the prompt. The bot can now combine its Role, its Goal, and its Data to provide a truly intelligent response.

The "How": We build a final prompt that includes a placeholder for our application's data.

# Our Application Data (from our database)
user_context = """
User Name: Bob
Device: Dell XPS 13 (2024)
OS: Windows 11
Support History: (None)
"""

# Our System Prompt
system_prompt = f"""
You are "Alex", an empathetic Tier 1 support agent.

Your tone is friendly and professional.

Your goal is to help the user solve their problem.

Here is the user's data:

<context>
{user_context}
</context>
"""

# Our User's Message
user_query = "My laptop won't connect to Wi-Fi. I've tried everything."

graph TD
subgraph BRAIN["The 'Brain' (System Prompt)"]
A["Role: 'Alex' (Empathetic)"]
B["Goal: Solve Problem"]
end
subgraph DATA["The 'Data' (Context)"]
C["User: Bob"]
D["Device: Dell XPS 13"]
E["OS: Windows 11"]
end

F["User: 'My laptop won't connect...'"] --> G(LLM)
BRAIN --> G
DATA --> G

G --> H["Bot: Provides personalized solution using Bob's device info and Windows 11 context"]

style H fill:#e8f5e9,stroke:#388e3c,color:#212121

What we built

By layering three simple techniques, we transformed our bot:

Zero-Shot (Problem): Useless.

+ Explicit Instructions: Became a useful info-gatherer.

+ Role Prompting: Became a friendly, empathetic agent.

+ Contextual Prompting: Became a specific and valuable expert.

Challenge for you

Add a "Tool": Modify the system prompt to give the bot a "tool" it can use. For example: You have one tool: 'check_outage(zip_code)'.

Test it: Ask a question like, "Is there a service outage in my area?" The bot should not make up an answer, but instead ask you for your zip code so it can "use" its tool.

Key takeaways

Explicit instructions define behavior: A clear goal in the system prompt transforms a generic bot into a focused tool

Role prompting shapes personality: Defining a persona makes interactions feel human and empathetic

Context makes bots intelligent: Injecting real-time data turns a helpful bot into a knowledgeable expert

Layering techniques multiplies effectiveness: Combining explicit instructions, role, and context creates production-ready agents