Featured image of post Semantic Kernel Prompts: Complete Guide to All Types with Examples for .NET AI Apps

Semantic Kernel Prompts: Complete Guide to All Types with Examples for .NET AI Apps

When building AI-native applications with Semantic Kernel, prompts are the instructions you give to an LLM like GPT-4 to generate intelligent responses.

Semantic Kernel Prompts: Complete Guide to All Types with Examples for .NET AI Apps

When building AI-native applications with Semantic Kernel, prompts are the instructions you give to an LLM like GPT-4 to generate intelligent responses.

This post is your complete guide to all prompt types in Semantic Kernel โ€” including how to define, use, and invoke them in your .NET app.


๐Ÿ” What is a Prompt in Semantic Kernel?

A prompt is a reusable, structured instruction that tells the AI model what to do. Prompts can be used inside:

  • Plugins (skills)
  • Agent logic
  • Planners
  • Workflows

๐Ÿ“ฆ Types of Prompts in Semantic Kernel

Below are all supported types, with examples:


1. ๐Ÿงพ Plain Text Prompt

Basic prompts stored inline or in .txt files.

1
2
Summarize this article in one paragraph:
{{$input}}

๐Ÿ“‚ File: summarize.skprompt.txt ๐Ÿ“ฅ Input passed using the {{$input}} placeholder.

โœ… Best for: Simple templated prompts.


2. โš™๏ธ Semantic Function Prompt (C# Inline)

Prompts defined in C# using CreateFunctionFromPrompt.

1
2
3
4
5
var prompt = "Write a professional email reply to:\n{{input}}";
var replyFunc = kernel.CreateFunctionFromPrompt(prompt);

var result = await kernel.InvokeAsync(replyFunc, new() { { "input", "Your shipment is delayed." } });
Console.WriteLine(result.GetValue<string>());

โœ… Best for: Quick integration into business logic.


3. ๐Ÿง  YAML Prompt Template

Advanced prompts with metadata, inputs, defaults, and model configs.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
name: blog_writer
description: Writes a blog post based on a topic
parameters:
  - name: topic
    description: Topic of the blog
    default: "AI and productivity"
template: |
  Write a 3-paragraph blog post about {{topic}}.
execution_settings:
  temperature: 0.7
  max_tokens: 500

โœ… Best for: Structured, reusable prompts with input schemas.


4. ๐Ÿ› ๏ธ Prompt with System Role (LLM Behavior Control)

You can set the system role using execution settings.

1
2
3
4
5
6
7
template: |
  Answer like a financial advisor with short, precise replies.

execution_settings:
  role: system
  temperature: 0.3
  top_p: 0.95

โœ… Best for: Controlling model persona or behavior.


5. ๐Ÿงฉ Composite Prompt (Chain Multiple Inputs)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
parameters:
  - name: intro
  - name: body
  - name: conclusion
template: |
  {{intro}}

  {{body}}

  {{conclusion}}

execution_settings:
  temperature: 0.6

โœ… Best for: Multi-section emails, reports, or formatted outputs.


6. ๐Ÿ”„ Function-Calling Prompt with Plugin Integration

Use a prompt that calls a plugin like MathPlugin.

1
2
3
4
5
6
public class MathPlugin
{
    [KernelFunction("add")]
    [Description("Adds two numbers")]
    public int Add(int a, int b) => a + b;
}

Prompt:

1
What is the result of 7 plus 5?

The LLM auto-selects add(7, 5) via function calling behind the scenes.

โœ… Best for: Allowing LLMs to use your business logic.


7. ๐Ÿงญ Step Prompt in a Workflow (Process Framework)

Used inside .yaml workflows:

1
2
3
4
5
6
7
8
steps:
  - name: ask_topic
    type: prompt
    template: "What topic would you like to write about?"

  - name: write_blog
    type: prompt
    template: "Write a blog post about {{ask_topic}}"

โœ… Best for: Guided multi-step user flows and automations.

โœ… Pro Tips for Prompt Design

  • Use clear, task-specific language
  • Add instructions + examples when possible
  • Use {{variable}} for flexibility
  • Lower temperature for consistency; raise it for creativity
  • Test different wording with real user inputs

๐Ÿ“š Learn More


๐Ÿ’ฌ Got a unique use-case or prompt format you’re working on? Drop it in the comments or tag me โ€” let’s learn together!

If this helped you, donโ€™t forget to โค๏ธ, ๐Ÿฆ„, or share it with your .NET AI builder friends!

comments powered by Disqus