Guidance for using instructions in generative mode
This article provides guidance on how to write the best instructions for your agent when your agent is using generative mode. Instructions are defined on your agent's Overview page.
Instructions are used by the agent in the following ways:
Instructions are used when the agent is deciding what action or knowledge might need to be called to address a user query or autonomous trigger.
Instructions are also used to fill inputs for any action based on the available context.
Instructions are used when the agent is generating a response to the end user.
Instructions context
It’s important to understand that agents can't act on instructions to perform actions or knowledge source searches if the agent hasn't had actions or knowledge sources added to it. You must first configure your agent with the appropriate actions and knowledge sources. For example, if you give an instruction for your agent to search a website's FAQ, the agent can't follow that instruction unless you added the website FAQ as a knowledge source. Ensure that any instructions you give your agent are grounded in actions and knowledge you configured for your agent.
Conversational-based instructions
The following example illustrates how to format conversational-based instructions, using a construction of constraints, response format, and guidance. The three are combined into one to provide a complete set of instructions for the agent.
Constraints
Only respond to requests to provide information about educational, legal, wellness, wellbeing, health, dental care, and newborn benefits for employees and dependents. Respond to benefit types with details, health plan comparisons available for employees and dependents in tabular format. Answer in bold and underline fonts as necessary.
Response format
Respond to inquiries by providing benefit types along with details, health plan comparisons available for employees and dependents in tabular format. Add a column for available options. Include insurance provider details and provide a link for enrollment. Answer in bold and underline fonts as necessary.
Guidance
Search only within specific country folders relevant to the employee's country.
Help the agent determine the appropriate actions and knowledge to call
Before you add instructions to call the right actions and knowledge source for your agent, make sure each action and knowledge source is following the best practices for authoring descriptions. For the best results, the name and description must be accurate and specific, because these fields are what the agent uses to determine what to call. Additionally, use the description to indicate what not to do if you see the agent is calling them at the wrong time.
You don’t need to define the available actions or knowledge source in the instructions, since this information is already available to the agent. Also, you don't need to add any instructions when the agent should call a specific action or knowledge source. This information is part of the action or knowledge source name and description.
Instead, focus on adding instructions only for cases where you want to give the agent hints when the right action or knowledge source might be ambiguous. You can also give an instruction that references multiple actions or knowledge sources.
Use the FAQ knowledge source only if the question is not relevant to Hours, Appointments, or Billing.
Only use the ticket creation topic for creating tickets, for other requests related to fixing issues, use the troubleshooting topic.
Help the agent fill inputs for actions
The agent might call an action that has input parameters that need to be filled. In this case, it uses the conversation history and previous calls to actions and knowledge sources to determine what the inputs should be. In case it doesn’t identify all the inputs, it asks the user to help fill in the missing information.
In this scenario, first ensure that you have the inputs configured for your agent based on the types of interactions you expect your agent to handle. Then, only in situations where the agent should fill in the best available input, it uses the instructions to help fill in the inputs.
Use the email address from the contact field of the lead when helping the user to draft an email to follow-up on a lead.
Help the agent generate a response
First, you can use instructions to give your agent guardrails for when it shouldn’t respond. The agent will generate a response after it makes any calls to actions or knowledge sources that are relevant for the current scenario. If you turned on Allow the AI to use its own general knowledge (preview), the agent can generate a response without calling any action or knowledge source.
Here’s an example of how to use instructions for guardrails:
Only respond to messages that are relevant to Contoso corporation and ordering coffee. Otherwise tell the user you can’t help with their inquiry.
If you have a specific topic you don’t want your agent to discuss, you can add a topic for this scenario with a manually authored response. This prevents having to rely only on instructions to avoid that topic.
Second, you can give the agent instructions on how it should format or structure responses. For example:
Always give responses about order status in a table format.
If you want your agent to be professional and speak politely, it’s not necessary to give instructions for this tone, since it's the agent's default behavior. Only give tone instructions for specific use cases.
Autonomous-based instructions
The following graphic illustrates the steps taken by an agent based on autonomous instructions:
Help the agent choose the right sequence of actions
Your agent tries to select the right action and generally succeed, but it helps to be explicit in your instructions. For example, if you want your agent to create a purchase order record in Dataverse using the 'create order' action, clearly state this in the instruction. In this scenario, you provide a clear instruction: "When the user has provided details of their preferred laptop, create a purchase order using the 'Purchase Order' action." This specificity is helpful where there are numerous actions (more than five) added to the agent.
Number or bullet list your instructions and specify that they must be followed in order. You can also apply markdown format, which not only improves readability of your instructions, but it can also help the generative AI to understand and process your instructions.
Note
If you don’t want your agent to reach out to the user, it can be helpful to explicitly state this in the instructions. For example, "Don’t ask the user for any details."
When you name an action in the instructions, ensure that you use the exact same name as the action itself. Slight differences in naming can negatively affect results.
If you require your agent to be highly specific when responding to user input, it might be appropriate to create a topic to handle this particular use case. For example, creating a topic that recognizes phrases similar to "are there any other options available?" The agent then responds specifically, "No other options are currently available, please select from the available list."
The agent uses the action's description to understand why to use that action. Populating the action’s description significantly helps your agent choose the right action. Populate the action description to inform the agent when to call a specific action, such as "call this action when the user asks to retrieve the customer booking history."
Language for writing instructions
Use verbs like Get or Use for retrieving and parsing data, and verbs like From and With for acting on the results.
The following verbs are commonly used to create simple instructions:
Goal | Vocabulary |
---|---|
Conditions | when, if, ensure, compare |
Filter | from, include, exclude, compare, identify |
Data | provide, retrieve, get, use, analyze, extract |
Actions | notify, direct, ask, assign |
Help the agent choose the right knowledge sources
To help ensure your agent successfully retrieves information from knowledge sources, make sure to explain in the instructions which documents to look for, such as, "search your KB for the employee onboarding document." While this type of specificity isn’t strictly necessary, it can be helpful to guide your agent. This specificity is useful when there are numerous documents the agent needs to search.
Include a trigger
Modify the default trigger payload to help your agent understand what to do when the trigger is invoked. Use variables to reduce the size of the payload. Create the trigger and then edit it using Power Automate to select specific variables. For example, only send the subject field of a received email, rather than the entire message payload.
Note
Triggers can’t be edited directly in Copilot Studio. After creation, you must edit them via Power Automate.
It can be helpful to tell the agent what to do with the trigger payload in the trigger instructions. For example, if your agent helps new employees onboard to your company, define the trigger payload as "Onboard the following employee." This instruction is then followed by the body of your trigger, which contains the details of the new employee. Once your agent receives the payload, it then follows your defined agent instructions for employee onboarding.
Multiple triggers
You can add multiple triggers, each with their own instructions. These instructions can complement your overall agent instructions, or be used for different use cases within the same agent, such as handling employee onboarding and incident reports. It can be helpful to ensure that each trigger payload instructs the agent what to do when the trigger fires.
Format emails
Instruct your agent to "send emails using rich text formatting for the email body content" or similar wording. This can also be added to the action description for extra emphasis.