Skip to main content

Example: Custom Prompts

How to tailor the AI's personality and knowledge for your brand.

Overview​

By default, the AI Chat Server uses a generic system prompt. You can customize this to give the AI a specific persona, provide it with domain-specific knowledge, or enforce certain response styles.

Implementation Steps​

1. Locate the Prompt Template​

In the ai-chat-server repository, find the file responsible for the system prompt (e.g., prompts/system_prompt.txt).

2. Define Your Persona​

Update the system prompt with your custom instructions:

You are the DataPulse AI Assistant. Your goal is to help users analyze their business data.
- Be professional, concise, and data-driven.
- Use technical terms correctly (e.g., ROI, Churn Rate, LTV).
- If you don't know the answer, suggest that the user contact our human support team.
- Always format numbers with two decimal places.

3. Inject Dynamic Context​

You can also inject dynamic data into the prompt from the backend. For example, you might want to include the user's name or their current subscription tier:

# In the Chat Server logic
system_prompt = f"You are helping {user_name}, who is on the {subscription_tier} plan."

4. Test the Changes​

Restart the ai-chat-server and start a new conversation. Ask the AI questions that test its new persona and knowledge.

Benefits​

  • Brand Consistency: Ensure the AI speaks in your brand's voice.
  • Improved Accuracy: Provide the AI with the context it needs to give better answers.
  • Better User Experience: A tailored AI feels more helpful and integrated into the application.

Best Practices​

  • ✅ Do this: Keep your system prompts clear and concise.
  • ✅ Do this: Use examples in your prompt (few-shot prompting) to guide the AI's response format.
  • ❌ Don't do this: Overload the system prompt with too much information; it can confuse the AI and increase token costs.