Prompt Engineering Tutorial menu

Giving the AI a Role

Giving the AI a role tells it what kind of expert to act as, which changes its focus, words and tone.

What is Role Prompting?

You start the prompt with "You are..." or "Act as...". The role helps the model choose the right knowledge and style.

Example

text
You are an experienced English teacher. Check my paragraph for
grammar mistakes. List each mistake, the correction, and a
one-line reason. Do not rewrite the whole paragraph.

Without the role, the AI might just rewrite your text. With the role and clear task, it teaches you.

Useful Roles

RoleGood for
Patient teacherExplaining a new topic simply
Strict examinerPractising for exams and getting honest marks
EditorImproving clarity and grammar
Senior developerReviewing code and finding bugs
Marketing expertAd copy, captions, campaign ideas
CustomerTesting your sales pitch from the buyer's side
InterviewerPractising for a job interview

Role + Audience + Tone

A role is strongest when you also say who the reader is and what tone to use:

Example

text
You are a friendly bank customer support agent.
A customer who is not good with technology asks how to
reset their mobile banking PIN. Reply in simple Roman Urdu,
in 4 short steps, with a calm and patient tone.

Roles in Apps: the System Prompt

When developers build a chatbot, they put the role in a hidden system message. Every user message is then answered in that role. Here is how such a conversation is structured in code:

Example

python
conversation = [
    {"role": "system",
     "content": "You are the assistant for Ayesha's Bakery in Karachi. "
                "Answer only questions about the menu, prices and delivery. "
                "Be polite and keep answers under 50 words."},
    {"role": "user", "content": "Do you deliver to Gulshan-e-Iqbal?"},
]
for message in conversation:
    print(message["role"].upper(), ":", " ".join(message["content"].split()[:8]))
Output
SYSTEM : You are the assistant for Ayesha's Bakery in
USER : Do you deliver to Gulshan-e-Iqbal?

The model sees both messages and answers as the bakery assistant. You will build this in the Chatbots tutorial.

Role Play for Practice

Roles are also great for practising real situations:

Example

text
Act as an interviewer for a junior web developer job.
Ask me one question at a time. After each answer, give
a score out of 10 and one tip to improve. Start now.

Limits of Roles

  • A role does not give the AI new knowledge. "You are a doctor" does not make medical answers safe to follow without a real doctor.
  • Very long, dramatic role descriptions rarely help more than one clear sentence.
  • The task and context still matter more than the role.

A role sets the style and focus. The facts still come from the model's training and the context you provide, so check important answers.

Exercise

Exercise

In a chatbot app, where is the bot's role usually placed?

Learn Prompt Engineering with a teacher

Join the AI & Prompt Engineering course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp