Instruction Configuration Guide
This guide covers creating and managing instruction configurations using the WIIL Platform JS SDK. Instruction configurations define the prompts, behavioral guidelines, and conversation flow for AI agents.
Quick Start​
- TypeScript
- Python
import { WiilClient, BusinessSupportServices } from 'wiil-js';
const client = new WiilClient({
apiKey: 'your-api-key',
});
// Create an instruction configuration
const instruction = await client.instructionConfigs.create({
instructionName: 'Customer Support Instructions',
role: 'Customer Support Specialist',
introductionMessage: 'Hello! How can I help you today?',
instructions: 'You are a helpful customer support agent. Focus on resolving customer issues efficiently.',
guardrails: 'Always be polite and professional. Never share sensitive customer data.',
supportedServices: [BusinessSupportServices.APPOINTMENT_MANAGEMENT],
});
console.log('Instruction created:', instruction.id);
from wiil import WiilClient
from wiil.models.service_mgt import CreateInstructionConfiguration
from wiil.models.type_definitions import BusinessSupportServices
client = WiilClient(api_key='your-api-key')
# Create an instruction configuration
instruction = client.instruction_configs.create(
CreateInstructionConfiguration(
instruction_name='Customer Support Instructions',
role='Customer Support Specialist',
introduction_message='Hello! How can I help you today?',
instructions='You are a helpful customer support agent. Focus on resolving customer issues efficiently.',
guardrails='Always be polite and professional. Never share sensitive customer data.',
supported_services=[BusinessSupportServices.APPOINTMENT_MANAGEMENT],
)
)
print(f'Instruction created: {instruction.id}')
Architecture Overview​
Instruction configurations are the heart of agent behavior in the WIIL platform:
- Central Role: Defines how agents operate during conversations
- 1:N Relationship: One instruction configuration can govern multiple Agent Configurations
- Reusability: Designed to be reused across multiple deployments
Example: A "Customer Service Guidelines" instruction set might govern both a "Sales Agent" and a "Support Agent", ensuring uniform tone and compliance.
Enums​
BusinessSupportServices​
- TypeScript
- Python
enum BusinessSupportServices {
APPOINTMENT_MANAGEMENT = 'appointment-management',
PRODUCT_ORDER_MANAGEMENT = 'product-order-management',
MENU_ORDER_MANAGEMENT = 'menu-order-management',
RESERVATION_MANAGEMENT = 'reservation-management',
PROPERTY_LISTING_MANAGEMENT = 'property-listing-management'
}
from wiil.models.type_definitions import BusinessSupportServices
# Available values:
BusinessSupportServices.APPOINTMENT_MANAGEMENT # 'appointment-management'
BusinessSupportServices.PRODUCT_ORDER_MANAGEMENT # 'product-order-management'
BusinessSupportServices.MENU_ORDER_MANAGEMENT # 'menu-order-management'
BusinessSupportServices.RESERVATION_MANAGEMENT # 'reservation-management'
BusinessSupportServices.PROPERTY_LISTING_MANAGEMENT # 'property-listing-management'
Instruction Configuration Schema​
| Field | Type | Required | Description |
|---|---|---|---|
| instructionName | string | Yes | System-readable name (e.g., 'customer-support-agent') |
| role | string | Yes | Role the agent adopts (e.g., 'Customer Support Specialist') |
| introductionMessage | string | Yes | Initial greeting message |
| instructions | string | Yes | Detailed behavioral guidelines and conversation flow |
| guardrails | string | Yes | Safety constraints and ethical guidelines |
| supportedServices | BusinessSupportServices[] | No | Platform business services (tools) enabled |
| knowledgeSourceIds | string[] | No | IDs of linked knowledge sources |
| requiredSkills | string[] | No | Skills required (e.g., 'appointment_booking') |
| validationRules | object | No | Custom validation rules |
| isTemplate | boolean | No | Whether this is a reusable template (default: false) |
| isPrimary | boolean | No | Whether this is the primary template (default: false) |
| metadata | object | No | Custom metadata |
CRUD Operations​
Create Instruction Configuration​
- TypeScript
- Python
const instruction = await client.instructionConfigs.create({
instructionName: 'Sales Agent Instructions',
role: 'Sales Representative',
introductionMessage: 'Hello! I can help you find the perfect solution for your needs.',
instructions: 'You are a knowledgeable and helpful sales agent. Focus on understanding customer needs and recommending appropriate solutions.',
guardrails: 'Always be honest about product capabilities. Never make promises the product cannot deliver. Respect customer privacy.',
supportedServices: [BusinessSupportServices.APPOINTMENT_MANAGEMENT],
metadata: { department: 'sales', version: '1.0' },
});
console.log('Created instruction:', instruction.id);
console.log('Instruction name:', instruction.instructionName);
from wiil import WiilClient
from wiil.models.service_mgt import CreateInstructionConfiguration
from wiil.models.type_definitions import BusinessSupportServices
client = WiilClient(api_key='your-api-key')
instruction = client.instruction_configs.create(
CreateInstructionConfiguration(
instruction_name='Sales Agent Instructions',
role='Sales Representative',
introduction_message='Hello! I can help you find the perfect solution.',
instructions='You are a knowledgeable and helpful sales agent. Focus on understanding customer needs and recommending appropriate solutions.',
guardrails='Always be honest about product capabilities. Never make promises the product cannot deliver. Respect customer privacy.',
supported_services=[BusinessSupportServices.APPOINTMENT_MANAGEMENT],
metadata={'department': 'sales', 'version': '1.0'},
)
)
print(f'Created instruction: {instruction.id}')
print(f'Instruction name: {instruction.instruction_name}')
Get Instruction Configuration​
- TypeScript
- Python
const instruction = await client.instructionConfigs.get('instr_123');
console.log('Instruction name:', instruction.instructionName);
console.log('Role:', instruction.role);
console.log('Introduction:', instruction.introductionMessage);
instruction = client.instruction_configs.get('instr_123')
print(f'Instruction name: {instruction.instruction_name}')
print(f'Role: {instruction.role}')
print(f'Introduction: {instruction.introduction_message}')
List Instruction Configurations​
- TypeScript
- Python
const result = await client.instructionConfigs.list({
page: 1,
pageSize: 20,
});
console.log('Total instructions:', result.meta.totalCount);
result.data.forEach(instruction => {
console.log(`- ${instruction.instructionName} (${instruction.id})`);
});
from wiil.types import PaginationRequest
result = client.instruction_configs.list(
params=PaginationRequest(page=1, page_size=20)
)
print(f'Total instructions: {result.meta.total_count}')
for instruction in result.data:
print(f'- {instruction.instruction_name} ({instruction.id})')
Update Instruction Configuration​
- TypeScript
- Python
const updated = await client.instructionConfigs.update({
id: 'instr_123',
introductionMessage: 'Hi! How may I assist you today?',
guardrails: 'Updated: Always be honest and transparent. Respect privacy and confidentiality.',
});
console.log('Updated introduction:', updated.introductionMessage);
from wiil.models.service_mgt import UpdateInstructionConfiguration
updated = client.instruction_configs.update(
UpdateInstructionConfiguration(
id='instr_123',
introduction_message='Hi! How may I assist you today?',
guardrails='Updated: Always be honest and transparent. Respect privacy.',
)
)
print(f'Updated introduction: {updated.introduction_message}')
Delete Instruction Configuration​
- TypeScript
- Python
const deleted = await client.instructionConfigs.delete('instr_123');
if (deleted) {
console.log('Instruction deleted successfully');
}
deleted = client.instruction_configs.delete('instr_123')
if deleted:
print('Instruction deleted successfully')
Get Supported Templates​
- TypeScript
- Python
const templates = await client.instructionConfigs.getSupportedTemplates();
console.log('Available templates:', templates.length);
templates.forEach(template => {
console.log(`- ${template.instructionName}: ${template.role}`);
});
templates = client.instruction_configs.get_supported_templates()
print(f'Available templates: {len(templates)}')
for template in templates:
print(f'- {template.instruction_name}: {template.role}')
Complete Example​
Full workflow demonstrating instruction configuration lifecycle:
- TypeScript
- Python
import { WiilClient, BusinessSupportServices } from 'wiil-js';
const client = new WiilClient({
apiKey: process.env.WIIL_API_KEY!,
});
async function manageInstructionConfigurations() {
// 1. Create instruction configuration
const instruction = await client.instructionConfigs.create({
instructionName: 'Technical Support Instructions',
role: 'Technical Support Specialist',
introductionMessage: 'Hello! I am your technical support specialist. How can I help you today?',
instructions: `You are a knowledgeable technical support agent.
- Listen carefully to understand the issue
- Ask clarifying questions when needed
- Provide step-by-step solutions
- Escalate complex issues appropriately`,
guardrails: `Safety guidelines:
- Never ask for passwords or sensitive credentials
- Do not make changes without customer confirmation
- Escalate security-related issues immediately
- Follow data protection regulations`,
supportedServices: [BusinessSupportServices.APPOINTMENT_MANAGEMENT],
metadata: { department: 'technical-support', tier: 'L1' },
});
console.log('Instruction created:', instruction.id);
// 2. Retrieve instruction by ID
const retrieved = await client.instructionConfigs.get(instruction.id);
console.log('Retrieved instruction:', retrieved.instructionName);
// 3. List all instructions
const allInstructions = await client.instructionConfigs.list({ page: 1, pageSize: 50 });
console.log('Total instructions:', allInstructions.meta.totalCount);
// 4. Update instruction configuration
const updated = await client.instructionConfigs.update({
id: instruction.id,
introductionMessage: 'Welcome to technical support! How can I assist you?',
metadata: { department: 'technical-support', tier: 'L1', updated: true },
});
console.log('Updated introduction:', updated.introductionMessage);
// 5. Use instruction with an agent configuration
const model = await client.supportModels.getDefaultMultiMode();
const agent = await client.agentConfigs.create({
name: 'TechSupportBot',
modelId: model!.modelId,
instructionConfigurationId: instruction.id,
});
console.log('Agent created with instruction:', agent.id);
// 6. Clean up
await client.agentConfigs.delete(agent.id);
console.log('Agent deleted');
await client.instructionConfigs.delete(instruction.id);
console.log('Instruction deleted');
}
manageInstructionConfigurations().catch(console.error);
import os
from wiil import WiilClient
from wiil.models.service_mgt import (
CreateInstructionConfiguration,
CreateAgentConfiguration,
UpdateInstructionConfiguration,
)
from wiil.models.type_definitions import BusinessSupportServices
from wiil.types import PaginationRequest
client = WiilClient(api_key=os.environ['WIIL_API_KEY'])
def manage_instruction_configurations():
# 1. Create instruction configuration
instruction = client.instruction_configs.create(
CreateInstructionConfiguration(
instruction_name='Technical Support Instructions',
role='Technical Support Specialist',
introduction_message='Hello! I am your technical support specialist.',
instructions='''You are a knowledgeable technical support agent.
- Listen carefully to understand the issue
- Ask clarifying questions when needed
- Provide step-by-step solutions
- Escalate complex issues appropriately''',
guardrails='''Safety guidelines:
- Never ask for passwords or sensitive credentials
- Do not make changes without customer confirmation
- Escalate security-related issues immediately
- Follow data protection regulations''',
supported_services=[BusinessSupportServices.APPOINTMENT_MANAGEMENT],
metadata={'department': 'technical-support', 'tier': 'L1'},
)
)
print(f'Instruction created: {instruction.id}')
# 2. Retrieve instruction by ID
retrieved = client.instruction_configs.get(instruction.id)
print(f'Retrieved instruction: {retrieved.instruction_name}')
# 3. List all instructions
all_instructions = client.instruction_configs.list(
params=PaginationRequest(page=1, page_size=50)
)
print(f'Total instructions: {all_instructions.meta.total_count}')
# 4. Update instruction configuration
updated = client.instruction_configs.update(
UpdateInstructionConfiguration(
id=instruction.id,
introduction_message='Welcome to technical support! How can I assist?',
metadata={'department': 'technical-support', 'tier': 'L1', 'updated': True},
)
)
print(f'Updated introduction: {updated.introduction_message}')
# 5. Use instruction with an agent configuration
models = client.support_models.list()
model = next(
(m for m in models if m.type == 'multi_mode' and not m.discontinued),
None
)
agent = client.agent_configs.create(
CreateAgentConfiguration(
name='TechSupportBot',
model_id=model.model_id,
instruction_configuration_id=instruction.id,
)
)
print(f'Agent created with instruction: {agent.id}')
# 6. Clean up
client.agent_configs.delete(agent.id)
print('Agent deleted')
client.instruction_configs.delete(instruction.id)
print('Instruction deleted')
if __name__ == '__main__':
manage_instruction_configurations()
Best Practices​
-
Write clear, detailed instructions - The instructions field is the core of agent behavior. Be specific about how the agent should respond, what tone to use, and how to handle different scenarios.
-
Define comprehensive guardrails - Guardrails protect your business and customers. Include compliance rules, forbidden topics, escalation criteria, and ethical guidelines.
-
Use supportedServices wisely - Only enable the business services (tools) that the agent needs. This follows the principle of least privilege.
-
Keep instruction names descriptive - Use kebab-case names that clearly describe the purpose (e.g., 'customer-support-sales', 'technical-support-l1').
-
Version your configurations - Use metadata to track versions. This helps with rollbacks and auditing.
-
Reuse instruction configurations - Design instruction sets to be reusable across multiple agents when they share common behavioral requirements.
Troubleshooting​
Missing Required Fields​
Error:
- TypeScript
- Python
WiilValidationError: instructionName is required
WiilValidationError: instruction_name is required
Solution: Ensure all required fields are provided:
- TypeScript
- Python
const instruction = await client.instructionConfigs.create({
instructionName: 'My Instructions', // Required
role: 'Assistant', // Required
introductionMessage: 'Hello!', // Required
instructions: 'Be helpful.', // Required
guardrails: 'Be safe.', // Required
});
instruction = client.instruction_configs.create(
CreateInstructionConfiguration(
instruction_name='My Instructions', # Required
role='Assistant', # Required
introduction_message='Hello!', # Required
instructions='Be helpful.', # Required
guardrails='Be safe.', # Required
)
)
Instruction Not Found​
Error:
- TypeScript
- Python
WiilAPIError: Instruction configuration not found
WiilAPIError: Instruction configuration not found
Solution: Verify the instruction ID exists before using it:
- TypeScript
- Python
try {
const instruction = await client.instructionConfigs.get('instr_123');
// Use instruction
} catch (error) {
if (error.code === 'NOT_FOUND') {
console.log('Instruction does not exist');
}
}
try:
instruction = client.instruction_configs.get('instr_123')
# Use instruction
except Exception as e:
if 'NOT_FOUND' in str(e):
print('Instruction does not exist')
Cannot Delete Instruction in Use​
Error:
- TypeScript
- Python
WiilAPIError: Cannot delete instruction configuration that is referenced by agent configurations
WiilAPIError: Cannot delete instruction configuration that is referenced by agent configurations
Solution: Delete or update agent configurations that reference this instruction first:
- TypeScript
- Python
// First, list agents using this instruction
const agents = await client.agentConfigs.list();
const usingInstruction = agents.data.filter(
a => a.instructionConfigurationId === 'instr_123'
);
// Delete or update those agents
for (const agent of usingInstruction) {
await client.agentConfigs.delete(agent.id);
}
// Now delete the instruction
await client.instructionConfigs.delete('instr_123');
# First, list agents using this instruction
agents = client.agent_configs.list()
using_instruction = [
a for a in agents.data
if a.instruction_configuration_id == 'instr_123'
]
# Delete or update those agents
for agent in using_instruction:
client.agent_configs.delete(agent.id)
# Now delete the instruction
client.instruction_configs.delete('instr_123')