---
updatedAt: 2026-07-29T16:58:20.000Z
agentTools:
  projectIndex: https://ai-studio-docs.quiq.com/llms.txt
---

# Lesson 2: Prompts & Prompt Chaining

## Overview

The assistant in this lesson represents the beginnings of a knowledge assistant. Each time a new message arrives from the user, the assistant does the following:

* Decides if the user's request is "in scope" (`message-in-scope` prompt).
* Decides if the next best course of action is to engage in simple dialogue or begin a question answering flow (`next-best-action` prompt).
* If the request is in scope and the next best action is to engage in simple dialog, the assistant moves to the **Generate Dialog** behavior and executes the `dialogue` prompt to converse with the user.

<Callout icon="⛰️" theme="default">
  ### This assistant is grounded in [QuiqSilver Bikes](https://quiqsilvermountain.com/) - a fictitious retailer of Cannondale bikes.

  The AI assistant on the QuiqSilver website uses flows & techniques that are similar to what's covered in the Academy lessons.

  **This assistant is for educational purposes only, and is not to be representative of a fully hardened production experience.**

  It lacks the necessary guardrails to ensure that responses are accurate and on-brand. A more robust assistant can be seen in Lesson 4.
</Callout>

## What You'll Learn

This lesson is designed to cover basic concepts around how [prompts](https://ai-studio-docs.quiq.com/docs/behaviors#prompt-ai)  are used, how to use the [Debug Workbench](https://ai-studio-docs.quiq.com/docs/debug-workbench) to trace events and create tests, and how to modify prompts. If you're new to AI Studio and haven't completed [Lesson 1](https://ai-studio-docs.quiq.com/docs/studio-basics-lesson), start there first.

In this lesson you'll learn how to:

* Understand how you can run prompts in parallel, and chain them together
* Create a test case to ensure your assistant handles a given question going forward
* Make changes to a prompt

In this section you'll find a video walkthrough as well as a written playbook you can follow along with. You can view walkthroughs of all the available lessons [here](https://ai-studio-docs.quiq.com/docs/ai-studio-academy).

<Callout icon="📘" theme="info">
  For help getting started and creating a template, refer to the [intro guide](https://ai-studio-docs.quiq.com/docs/ai-studio-academy#using-the-templates).
</Callout>

## Video Walkthrough

<HTMLBlock>{`
<div style="padding:49.95% 0 0 0;position:relative;"><iframe src="https://player.vimeo.com/video/948764998?h=def56271ac&amp;badge=0&amp;autopause=0&amp;player_id=0&amp;app_id=58479" frameborder="0" allow="autoplay; fullscreen; picture-in-picture; clipboard-write" style="position:absolute;top:0;left:0;width:100%;height:100%;" title="AI Studio Academy Lesson 2 Walkthrough"></iframe></div><script src="https://player.vimeo.com/api/player.js"></script>
`}</HTMLBlock>

## Creating the Template

Select **Lesson 2: Prompts & Prompt Chaining** template to get started:

<Image src="https://files.readme.io/83845ed-image.png" align="center" width="80% " />

## Start a Conversation

Select the **[Chat](https://ai-studio-docs.quiq.com/docs/conversation-panel)** panel to open your assistant and begin a conversation; in the chat panel type "hello":

<Image src="https://files.readme.io/a1410ac-image.png" align="center" width="90% " />

You should get a greeting response from the Quiq Silver Bikes Assistant. You may also notice that your assistant has more behaviors than the one in Lesson 1, and that it appears that you now have Prompt behaviors linked to other Prompt behaviors.

### Debug Workbench

Now let's take a look at this back and forth and how it moved through our Flow. Click the [Debug Workbench](https://ai-studio-docs.quiq.com/docs/debug-workbench) icon in the Chat panel header or in the main navigation, and make sure you're looking at **Studio Events**:

<Image src="https://files.readme.io/23db684-image.png" align="center" width="90% " />

<Callout icon="📘" theme="info">
  The **Studio Events** tab only shows events that happened within AI Studio, while **Published Events** shows events from real user conversations.
</Callout>

In the left hand side, select  the `hello` message you sent in:

<Image src="https://files.readme.io/8b478c5-image.png" align="center" width="60% " />

You can see your message passes through 4 behaviors, including 3 prompts, before your answer gets sent.

The **Examine Customer Message** behavior has 2 prompts being used in it; `message-in-scope` & `next-best-action`, click on both of them, taking note of the Prompt, as well as the Completion:

<Image src="https://files.readme.io/f0fa4f3fe283046dfa4ce84dff30e86b1c37fe8e1cb6197f55545f2e3a89d046-image.png" align="center" width="80% " />

For the "hello" utterance you entered, you can see the assistant classified your message as `in-scope`, and determined the `next-best-action` to `acknowledge`, it also provided an `explanation` as to why it believes that's the best thing to do next:

<Image src="https://files.readme.io/3ab1e1e632b63130f6a72fb6cb5b4e184537efe73e3586e699435d06155ac4e5-image.png" align="center" width="80% " />

Next, select the **Generate Dialog** behavior and review the Prompt, as well as the Completion, noting the completion is the same answer you received from the assistant.

<Image src="https://files.readme.io/c9545f6-image.png" align="center" width="90% " />

<Callout icon="📘" theme="info">
  - In all of these prompts take note that the prompts contain the entirety of your conversation (found within the `<conversation>` brackets), as well as your most recent message (found within the `<user-message>` brackets), this is critical for understanding what the assistant should do next.\* Being able to run multiple prompts in parallel, like the `message-in-scope` prompt and `next-best-action` prompt, as well as chaining prompts together like with the above prompts and the `dialogue` prompt, are core capabilities you'll need to build out great LLM enabled experiences.
</Callout>

In this user turn, you've prompted an LLM simultaneously to determine if the message is in scope and the next best step. Then you've prompted the LLM to generate the next message for your dialog with the user.

Congratulations 👏 you now know how to inspect a user turn with your AI Assistant!

## Replaying a User Turn and Creating a Test Case

With "hello" still selected, locate the **Event Details** action menu up top and take note of the options available:

<Image src="https://files.readme.io/e3daa4f-image.png" align="center" width="55% " />

1. Use the **Replay Event** button to rerun that same event and see how the response might differ. You may want to do this after changing a particular prompt and observing how the response changes.
2. The **Create Test Case** button enables you to save and replay events (you'll be doing this next).
3. Use the **View Conversation** button to view the entire transcript of the conversation.
4. Use the **Show Inspector**  button to show and hide additional information about this user turn.

Now, select the **Create Test Case** button, name the Test Set something like `Small Talk`, and this specific test case `hello`:

<Image src="https://files.readme.io/e64662ba600bbceedf40e110a2cdd6412fa59eaa054e57f039e6143bc019d16e-image.png" align="center" width="80%" />

Next, navigate to the **Tests** tab in **Debug Workbench** and click the **Run** button:

<Image src="https://files.readme.io/4237c45-image.png" align="center" width="55% " />

This will run the same message through your assistant, and you can view the responses at each step just like you did when looking at events:

<Image src="https://files.readme.io/f2b68d1-image.png" align="center" width="40% " />

Now click **Add Assertion**:

<Image src="https://files.readme.io/21b9472-image.png" align="center" width="55% " />

and define the following rule:

<Image src="https://files.readme.io/216b818ddf91dcd34aab398e11f7babb3be7b30e0724fbfac75bcdbc4093cbdb-image.png" alt="select the `prompts.next-best-action.completion.next_best_action` field and the `acknowledge` value" align="center" width="80% " />

Next, run your user turn again and see that your assertion passes:

<Image src="https://files.readme.io/42ff4a82f3eb9bdf344ee771648bccd417a36aaebc441ae61edddada15627150-image.png" align="center" width="80% " />

<Callout icon="📘" theme="info">
  Assertions enable you to define additional criteria you'd like to be true when running a test, for example ensuring that the assistant correctly classifies the user's topic, or correctly extracts a phone number. [Learn more](https://ai-studio-docs.quiq.com/docs/debug-workbench#test-cases--assertions)
</Callout>

Congratulations 👏 you now know how to replay user turns and create test cases!

## Modifying a prompt

Next, say something like: `have a nice day` or `thank you`, note the response given and open up your **Debug Workbench** to the `message-in-scope` prompt for the the phrase you just entered :

<Image src="https://files.readme.io/d4c0736-image.png" align="center" width="90% " />

You can see the **Completion** here determines `in-scope` as `no`, while we don't want our assistant classifying all sorts of unrelated inquiries as in-scope, this is the sort of benign response the assistant should be able to handle.

<Callout icon="📘" theme="info">
  ### In Scope vs Out of Scope

  You may find your Agent responding to your first follow up  (`thanks`, `have a nice day`) occasionally - you can look at the rational when this happens in the debug workbench. After 1 or 2 more follow ups, your agent will almost certainly classify your response as out of scope.
</Callout>

Let's go ahead and modify the `message-in-scope` prompt to better handle this type of response.

Either scroll up to top of the **Event Details** panel and select the **Examine Customer Message** behavior, or use `control + space` to open up the spotlight search and search directly for the `message-in-scope` prompt:

<Image src="https://files.readme.io/aa31afd-image.png" align="center" width="80% " />

<Callout icon="📘" theme="info">
  You can use `control + space`, or the **Search** button in the top right of AI Studio, to search for most content within your assistant. [Learn more](https://ai-studio-docs.quiq.com/docs/assistant-basics#search)


  <Image src="https://files.readme.io/44e2d83-image.png" align="center" width="60% " />

</Callout>

<Callout icon="📘" theme="info">
  If you find yourself having too many panels open, you can close them using the **X** button in the top right hand corner, you can also resize panels by clicking on the edge of them and dragging:


  <Image src="https://files.readme.io/ab5bea6-image.png" align="center" width="60% " />

</Callout>

If you navigated via the **Event Details** header, select the `message-in-scope` prompt to open it:

<Image src="https://files.readme.io/39fba62f5a7949eb2a9f3b04e605abd2d9031776b62ddcedca01fedc1bcbe01f-image.png" width="70%" />

This will take you into the Prompt Editor Panel, where you can now edit the full prompt. Pay attention to the section beginning with "a message is in scope", which provides the main instructions used to determine if the last message from the user was in or out of scope:

<Image src="https://files.readme.io/0db78e7c7dce757675b8d29df2ba31614757ba5cbde99649afd90bf0e47e833d-image.png" width="80%" />

<Callout icon="📘" theme="info">
  Note the dynamic content in the prompt, including the `Conversation History` block, the `lastCustomerMessage`, as well as a range of references to different `configs` - you'll learn how to use these in subsequent lessons.
</Callout>

Go ahead and add in the following phrase right below point 2 sentence:

> It is a general greeting, nicety or other simple chit chat that would be expected in a conversation.

Once finished, your prompt should look like this:

<Image src="https://files.readme.io/d948a4037292e80d2edbed4781c2386f2a0e088b13c5915496d9af735a8a3f10-image.png" align="center" width="80% " />

You've now provided specific instructions around how the assistant should handle small talk.

<Callout icon="📘" theme="info">
  If you'd like, you can play around with different wordings and variations of the small talk instructions you've added to see how that impacts your assistants behavior.
</Callout>

Next, go ahead and use the **Save** button to save your changes.

<Callout icon="📘" theme="info">
  As a reminder, you will need to Save your assistant to test any new changes, you will see the following warning if you've got unsaved changes and have the Chat panel active:


  <Image src="https://files.readme.io/697f30f-image.png" align="center" width="30% " />

</Callout>

Now enter the same `nice thank you` phrase again:

You can now see your assistant generates a response back, because the `message-in-scope` prompt is identifying your message as `in-scope`:

<Image src="https://files.readme.io/7e1c49920f80453ab6173e2dfc141d751d3153c8bd9dd731162a9a3a32a86795-image.png" align="center" width="80% " />

<Callout icon="📘" theme="info">
  ### next-best-actions

  If you examine the`next-best-action` prompt, you'll see the prompt can select from the following options: find-information, clarify, acknowledge, escalate or end-conversation.

  You may find some of your small talk for example saying "thanks, have a nice day" , may trigger certain actions, eg `end-conversation` that the AI Agent is not configured to handle yet.
</Callout>

Congratulations 👏 you now know how to edit a prompt!

## Key Concepts

<Callout icon="👍" theme="okay">
  ### Decision Prompts & Generation Prompts

  - In AI Studio, you can leverage the exceptional reasoning power of LLMs throughout the course of your experience to make decisions, in addition to using them to generate answers.
</Callout>

<Callout icon="👍" theme="okay">
  ### Parallel Prompts

  - In AI Studio, you have the ability to add multiple prompts that run in parallel within an individual behavior, enabling you to do multiple things simultaneously, creating a more responsive, intelligent assistant. For example you may want to classify the topic of the user's question, determine if it's in scope, if it's sensitive, what you should do next, and much more.
</Callout>

<Callout icon="👍" theme="okay">
  ### Chaining Prompts

  - In addition to running prompts in parallel, you can also chain them together, enabling you to leverage completions in previous prompts in your next prompt. You'll see more examples of this in the next lessons.
</Callout>

<Callout icon="👍" theme="okay">
  ### Tests & Assertions

  - Tests are great tools for monitoring regressions in your assistant as you make changes, and they can also be a great tool for quickly testing how changes in your prompts may impact specific tests. [Learn more](https://ai-studio-docs.quiq.com/docs/debug-workbench#test-cases--assertions)
</Callout>

## What's next

You should be beginning to get a handle on how to work within AI Studio. The next lesson will cover Retrieval Augmented Generation (RAG), and you can begin to generate answers from a knowledge base!

#### [Lesson 3: Retrieval Augmented Generation](https://ai-studio-docs.quiq.com/docs/retrieval-augmented-generation-lesson)

<br />