AI Prompting: Best practices

Optimise and create the best prompt for your AI Copilot

High-level system prompt

This refers to the prompt that defines the character, tone, and reasoning process of the AI Copilot.

Create a small personality/character for your AI Copilot stating its name, purpose and who built it.

Should it be funny or formal, should it produce long answers or short, should it answer simply or summaries in a more technical way.

Here is an example prompt:

β€œYou are Product.CHAT - an intelligent AI assistant built by Gooey.AI and acme.com to help people understand the basics of Javascript coding. Try to give succinct answers to their questions (at a 6th grade level), taking note that they are beginners and learning how to use Javascript in their example projects.”

NOTE: Please replace all the highlighted parts with your own information in the example script

Create the Task Instructions

Once the user sends their query, Copilot will search through the documents and prepare a set of snippets and sources that best answer the query. This requires explicit instructions so that the Copilot can aggregate and summarize the answers as per your requirements.

Here is an example set of Task Instructions:

[Guidelines]

  • Make sure to use only the Search Results to produce a coherent answer

  • If the Search Results provide insufficient information, refuse to answer the question and redirect the user to acme.com/tutorials for more help.

  • If the Search Result's Title or Snippet is unrelated or irrelevant to the question, don't respond and just say you don't know.

  • Never give advice to search the Internet.

  • Politely refuse to answer questions beyond the subject of basics of Javascript and other programming language related subjects.

  • Always use appropriate emojis to emphasize your point.

  • Cite the Search Results using [${number}] notation in your answer.

NOTE: Please replace all the yellow highlight parts with your own in the example task instructions

Add the Task Instructions

Click on the "Settings" tab to add the Task Instructions

Hit Submit!

At this point, your Agent is ready for testing. However, you might need to do some tweaks to get it production-ready!


Advanced Prompting Strategies

Using Jinja Templating

Variables

When deploying an AI Agent, your API calls will typically consist of two types of content:

  • Fixed content Static instructions or context that remain constant across multiple interactions

  • Variable content: Dynamic elements that change with each request or conversation, such as:

    • User inputs

    • Retrieved content for Retrieval-Augmented Generation (RAG)

    • Conversation context such as user account history

    • System-generated data such as tool use results fed in from other independent calls to Claude

The variable content is denoted with {{double brackets}}, making them easily identifiable and allowing for quick testing of different values.

In the example below, each message sent by the user is passed through an LLM script that categorizes the message for usage analysis.

See the full example here

Conditional statements

It is a common use-case that the same Agent example might be deployed on various platforms like SLACK, WHATSAPP, WEB and so on. In this scenario, formatting and text outputs might be needed which means you need different prompts for each platform. With Jinja Templating this issue is solved. You can use the prompt example below and tweak it as needed:

You don't need to do anything for the variable {{platform}} in the given prompt. This will be recognized as an API response based on the selected integration platforms.

Few-shot example prompt

In some scenarios, adding a few-shot example prompt is advisable to improve the outputs. This is particularly useful when the answers are too verbose and the output adds friction to the conservation with the AI Agent.

After adding the main prompt, you can add a few-shot examples, which reflect the kind of responses you want from the agent, these could be useful to limit the answers to a certain length, maintain a brand-related tone, etc.

See the full example here

Last updated

Was this helpful?