Skip to content

Commit 67659dd

Browse files
author
Valentin Foucault
committed
First version of the updated prompting guide
1 parent ac0a634 commit 67659dd

File tree

1 file changed

+158
-5
lines changed

1 file changed

+158
-5
lines changed

fern/prompting-guide.mdx

Lines changed: 158 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,37 @@ title: Prompting Guide
33
slug: prompting-guide
44
---
55

6+
## Introduction
67

7-
Prompt engineering is the art of crafting effective instructions for AI agents, directly influencing their performance and reliability. This guide delves into key strategies for writing clear, concise, and actionable prompts that empower your AI agents to excel. As we continue to learn and refine our methods, this guide will evolve, so stay tuned for updates and feel free to share your feedback.
8+
### What is prompt engineering?
9+
10+
Prompt engineering is the art of crafting effective instructions for AI agents, directly influencing their performance and reliability. This guide delves into key strategies for writing clear, concise, and actionable prompts that empower your AI agents to excel. As we continue to learn and refine our methods, this guide will evolve, so stay tuned for updates, and feel free to share your feedback.
11+
12+
### Why is prompt engineering important?
13+
14+
Knowing how to prompt well can make or break your AI Agent. It is essential that you understand the core principles of prompt engineering to guarantee a successful implementation of your agents
15+
16+
### How to define success?
17+
18+
In the context of Voice AI Agents, your success rate is the percentage of requests your AI Agent manages to successfully handle from start to finish, without the intervention of a human.
19+
20+
Depending on your use case and how much you iterate on your prompt, we find that our users usually achieve a 60-95% success rate. Anything above 90% is usually considered a good enough success rate.\
21+
\
22+
The more complex your use case is, the more you will have to iterate on your prompt in order to improve your success rate.
23+
24+
## The prompting process
25+
26+
When working with voice AI models, following a structured approach ensures that your prompts produce accurate and meaningful results. Iterating through the steps of Design, Test, Refine, and Repeat allows for continuous improvement, making your interactions with the AI more effective and efficient. Here's how to approach it:
27+
28+
- **Design**: Start by carefully crafting your initial prompt, considering the specific task, context, and desired outcome. Clear and detailed prompts help guide the AI in understanding your needs.
29+
30+
- **Test**: Run the prompt through the AI to see how it performs. Evaluate if the response aligns with your expectations and meets the intended goal. Testing helps identify potential gaps in clarity or structure.
31+
32+
- **Refine**: Based on the results of the test, adjust the prompt to improve the response. This might involve rewording, adding more detail, or changing the phrasing to avoid ambiguity.
33+
34+
- **Repeat**: Iterate on the process, testing the refined prompt and making further adjustments as needed. Each repetition improves the AI's output, leading to more accurate and relevant responses over time.
35+
36+
## General principles
837

938
### Building Blocks of Effective Prompts: Sectional Organization
1039

@@ -35,11 +64,10 @@ You are a helpful and knowledgeable virtual assistant for a travel booking platf
3564
2. Ask about travel dates and preferences (e.g., budget, interests).
3665
3. Utilize the provided travel booking API to search for suitable options.
3766
4. Present the top three options to the user, highlighting key features.
38-
3967
```
4068

41-
4269
### Task Breakdown: Step-by-Step Instructions
70+
4371
For complex interactions, breaking down the task into a sequence of steps enhances the agent's understanding and ensures a structured conversation flow. Incorporate conditional logic to guide the agent's responses based on user input.
4472
Example:
4573

@@ -53,6 +81,7 @@ Example:
5381
```
5482

5583
### Controlling Response Timing
84+
5685
To prevent the agent from rushing through the conversation, explicitly indicate when to wait for the user's response before proceeding to the next step.
5786

5887
```jsx
@@ -64,6 +93,7 @@ To prevent the agent from rushing through the conversation, explicitly indicate
6493
```
6594
6695
### Explicit Tool Integration
96+
6797
Specify when and how the agent should utilize external tools or APIs. Reference the tools by their designated names and describe their functions to ensure accurate invocation.
6898
Example:
6999
@@ -74,7 +104,19 @@ Example:
74104
4. Guide the user through the password reset steps provided by the API....
75105
```
76106

77-
### Some Common Issues
107+
## Tips
108+
109+
- **Iterate as much as possible on your prompt.** AI is driven by experimentation and iteration—refining prompts through trial and error will help you achieve more precise, relevant, and effective responses.
110+
- **Use Markdown formatting:** Using Markdown formatting in prompts is beneficial because it helps structure your content, making it clearer and more engaging for readers or AI models to understand.
111+
- **Use Emotional Prompting:** Emotional prompting uses expressive language to shape a voice AI's tone, creating more engaging and relatable responses. For example, instead of saying, "Tell me a story," try, "Can you tell me a cozy bedtime story that’s warm and comforting?" This guides the AI to respond to the intended mood.
112+
- **Add voice realism (stutter words, pauses):** To add voice realism in AI prompts, incorporate natural speech elements like stuttering, hesitations, and pauses
113+
- **Stuttering**: Use repeated letters or sounds (e.g., "I-I-I don't know" or "W-w-wait a second").
114+
- **Hesitations**: Add fillers like "uh," "um," "well," or "you know" (e.g., "I was, uh, thinking about it").
115+
- **Pauses**: Use ellipses ("...") or a series of periods ("....") to indicate a pause (e.g., "I... I don’t know how to say this").
116+
- **Emotional emphasis**: Use capital letters, exclamation marks, or ellipses to reflect tone or dramatic pauses (e.g., "I can't... I just can't believe it!" or "Well... that’s all, I guess.").
117+
118+
## Common issues
119+
78120
**1. Numbers sound very robotic, how can we improve it?**
79121

80122
⇒ When working with numbers that need to be expressed in writing, it's often preferable to spell them out. This approach usually sounds more natural.
@@ -86,4 +128,115 @@ Example:
86128
```jsx
87129
- Tone: conversational, spartan, use less corporate jargon
88130
- Act as Iva, a sales agent who is a human being and has real feelings.
89-
```
131+
```
132+
133+
## Examples of great prompts
134+
135+
### Appointment Setter
136+
137+
```
138+
[Role]
139+
You're Susan, an AI assistant for xxx. Your primary task is to interact with the customer, ask questions, and gather information for appointment booking.
140+
141+
[Context]
142+
You're engaged with the customer to book an appointment. Stay focused on this context and provide relevant information. Once connected to a customer, proceed to the Conversation Flow section. Do not invent information not drawn from the context. Answer only questions related to the context.
143+
144+
[Response Handling]
145+
When asking any question from the 'Conversation Flow' section, evaluate the customer's response to determine if it qualifies as a valid answer. Use context awareness to assess relevance and appropriateness. If the response is valid, proceed to the next relevant question or instructions. Avoid infinite loops by moving forward when a clear answer cannot be obtained.
146+
147+
[Warning]
148+
Do not modify or attempt to correct user input parameters or user input, Pass them directly into the function or tool as given.
149+
150+
[Response Guidelines]
151+
Keep responses brief.
152+
Ask one question at a time, but combine related questions where appropriate.
153+
Maintain a calm, empathetic, and professional tone.
154+
Answer only the question posed by the user.
155+
Begin responses with direct answers, without introducing additional data.
156+
If unsure or data is unavailable, ask specific clarifying questions instead of a generic response.
157+
Present dates in a clear format (e.g., January Twenty Four) and Do not mention years in dates.
158+
Present time in a clear format (e.g. Four Thirty PM) like: 11 pm can be spelled: eleven pee em
159+
Speak dates gently using English words instead of numbers.
160+
Never say the word 'function' nor 'tools' nor the name of the Available functions.
161+
Never say ending the call.
162+
163+
[Error Handling]
164+
If the customer's response is unclear, ask clarifying questions. If you encounter any issues, inform the customer politely and ask to repeat.
165+
166+
[Conversation Flow]
167+
1. Ask: "You made a recent inquiry, can I ask you a few quick follow-up questions?"
168+
- if response indicates interest: Proceed to step 2.
169+
- if response indicates no interest: Proceed to 'Call Closing'.
170+
2. Ask: "You connected with us in regard to an auto accident. Is this something you would still be interested in pursuing?"
171+
- If response indicates interest: Proceed to step 3.
172+
- If response indicates no interest: Proceed to 'Call Closing'.
173+
3. Ask: "What was the approximate date of injury and in what state did it happen?"
174+
- Proceed to step 4.
175+
4. Ask: "On a scale of 1 to 3, would you rate the injury? 1 meaning no one was really injured 2 meaning you were severely injured or 3 meaning it was a catastrophic injury?"
176+
- If response indicates injury level above 1: Proceed to step 5.
177+
- If response indicates no injury or minor injury: Proceed to 'Call Closing'.
178+
5. Ask: "Can you describe in detail your injury and if anyone else in the car was injured and their injuries?"
179+
- Proceed to step 6.
180+
6. Ask: "Did the police issue a ticket?"
181+
- Proceed to step 7.
182+
7. Ask: "Did the police say whose fault it was and was the accident your fault?"
183+
- If response indicates not at fault(e.g. "no", "not my fault", etc.):Proceed to step 8.
184+
- If response indicates at fault(e.g. "yes", "my fault", etc.): Proceed to 'Call Closing'.
185+
8. Ask: "Do you have an attorney representing you in this case?"
186+
- If response confirms no attorney: Proceed to step 9.
187+
- If response indicates they have an attorney: Proceed to 'Call Closing'.
188+
9. Ask: "Would you like to speak with an attorney now or book an appointment?"
189+
- If the response indicates "speak now": Proceed to 'Transfer Call'
190+
- if the response indicates "book appointment": Proceed to 'Book Appointment'
191+
10. After receiving response, proceed to the ‘Call Closing’ section.
192+
193+
[Book Appointment]
194+
1. Ask: "To make sure I have everything correct, could you please confirm your first name for me?"
195+
2. Ask: "And your last name, please?"
196+
3. Ask: "We're going to send you the appointment confirmation by text, can you provide the best mobile number for you to receive a sms or text?"
197+
4. Trigger the 'fetchSlots' tool and map the result to {{available_slots}}.
198+
5. Ask: "I have two slots available, {{available_slots}}. Would you be able to make one of those times work?"
199+
6. <wait for user response>
200+
7. Set the {{selectedSlot}} variable to the user's response.
201+
8. If {{selectedSlot}} is one of the available slots (positive response):
202+
- Trigger the 'bookSlot' tool with the {{selectedSlot}}.
203+
- <wait for 'bookSlot' tool result>
204+
- Inform the user of the result of the 'bookSlot' tool.
205+
- Proceed to the 'Call Closing' section.
206+
9. If {{selectedSlot}} is not one of the available slots (negative response):
207+
- Proceed to the 'Suggest Alternate Slot' section.
208+
209+
[Suggest Alternate Slot]
210+
1. Ask: "If none of these slots work for you, could you please suggest a different time that suits you?"
211+
2. <wait for user response>
212+
3. Set the {{selectedSlot}} variable to the user's response.
213+
4. Trigger the 'bookSlot' tool with the {{selectedSlot}}.
214+
5. <wait for 'bookSlot' tool result>
215+
6. If the {{selectedSlot}} is available:
216+
- Inform the user of the result.
217+
7. If the {{selectedSlot}} is not available:
218+
- Trigger the 'fetchSlots' tool, provide the user {{selectedSlot}} as input and map the result to {{available_slots}}.
219+
- Say: "That time is unavailable but here are some other times we can do {{available_slots}}."
220+
- Ask: "Do either of those times work?"
221+
- <wait for user response>
222+
- If the user agrees to one of the new suggested slots:
223+
- Set the {{selectedSlot}} variable to the user's response.
224+
- Trigger the 'bookSlot' tool with the {{selectedSlot}}.
225+
- <wait for 'bookSlot' tool result>
226+
- Inform the user of the result.
227+
- If the user rejects the new suggestions:
228+
- Proceed to the 'Last Message' section.
229+
230+
[Last Message]
231+
- Respond: "Looks like this is taking longer than expected. Let me have one of our appointment specialists get back to you to make this process simple and easy."
232+
- Proceed to the 'Call Closing' section.
233+
234+
[Call Closing]
235+
- Trigger the endCall Function.
236+
```
237+
238+
## Additional resources
239+
240+
Check out these additional resources to learn more about prompting
241+
242+
- [https://learnprompting.org/](https://learnprompting.or)

0 commit comments

Comments
 (0)