# Dynamic Agent Setup Guide **Simplified, single-call AI agent deployment** This guide covers the Dynamic Agent Setup API - a streamlined approach to deploying AI agents that abstracts the multi-step configuration process into single API calls. --- ## Table of Contents 1. [Introduction](#introduction) 2. [Quick Start](#quick-start) 3. [Phone Agent Setup](#phone-agent-setup) 4. [Web Agent Setup](#web-agent-setup) 5. [Updating Configurations](#updating-configurations) 6. [Voice Configuration (STT/TTS)](#voice-configuration-stttts) 7. [Role Templates & Capabilities](#role-templates--capabilities) 8. [Error Handling](#error-handling) 9. [Best Practices](#best-practices) --- ## Introduction ### What is Dynamic Agent Setup? The Dynamic Agent Setup API provides a **simplified alternative** to the traditional [Fundamental Configuration Setup](./fundamental-configuration-setup.md) workflow. Instead of making 7+ separate API calls to create instruction configs, agent configs, deployment channels, and deployment configurations, you can deploy a fully functional AI agent with a single API call. ### Comparison | Traditional Setup | Dynamic Setup | | ----------------- | ------------- | | 7+ separate API calls | Single API call | | Create instruction config | Auto-generated | | Create agent config | Auto-generated | | Create deployment channel | Auto-generated | | Create deployment config | Auto-generated | | Manual linking | Automatic | ### When to Use Dynamic Setup **Choose Dynamic Setup when:** - Rapid prototyping and testing - Standard use cases without complex customization - Quick deployments for demos or MVPs - You want simplicity over granular control **Choose Traditional Setup when:** - You need fine-grained control over each configuration - Custom instruction configurations with detailed guidelines - Complex multi-agent deployments - Advanced deployment channel configurations ### Prerequisites 1. **WIIL Platform Account** - Sign up at [https://console.wiil.io](https://console.wiil.io) 2. **API Key** - Generate in **Settings** → **API Keys** 3. **SDK Installation**: ```bash npm install wiil-js # or yarn add wiil-js ``` --- ## Quick Start ### Minimal Phone Agent ```typescript import { WiilClient } from 'wiil-js'; import { BusinessSupportServices } from 'wiil-core-js'; const client = new WiilClient({ apiKey: process.env.WIIL_API_KEY! }); const result = await client.dynamicPhoneAgent.create({ assistantName: 'Sarah', capabilities: [BusinessSupportServices.APPOINTMENT_MANAGEMENT], }); console.log('Phone number:', result.phoneNumber); console.log('Agent ID:', result.agentConfigurationId); ``` ### Minimal Web Agent ```typescript import { WiilClient } from 'wiil-js'; import { BusinessSupportServices } from 'wiil-core-js'; const client = new WiilClient({ apiKey: process.env.WIIL_API_KEY! }); const result = await client.dynamicWebAgent.create({ assistantName: 'Emma', websiteUrl: 'https://example.com', capabilities: [BusinessSupportServices.APPOINTMENT_MANAGEMENT], }); console.log('Integration snippets:', result.integrationSnippets); console.log('Agent ID:', result.agentConfigurationId); ``` --- ## Phone Agent Setup ### Overview The Dynamic Phone Agent API provisions a phone-based AI agent with automatic phone number assignment. ### Required Fields | Field | Type | Description | | ----- | ---- | ----------- | | `assistantName` | `string` | Name of the AI assistant | | `capabilities` | `BusinessSupportServices[]` | Platform services enabled for this agent | ### Optional Fields | Field | Type | Description | | ----- | ---- | ----------- | | `role_template_identifier` | `AgentRoleTemplateIdentifier` | Role/persona for the agent | | `language` | `string` | Language code (default: `"en"`) | | `phoneConfigurationId` | `string` | Existing phone configuration to use | | `testPhoneNumber` | `string` | Phone number for testing | | `instructionConfigurationId` | `string` | Existing instruction config to use | | `knowledgeSourceIds` | `string[]` | Knowledge sources to associate | | `voice` | `string` | Voice ID for the assistant | | `providerType` | `SupportedProprietor` | AI model provider | | `providerModelId` | `string` | Specific model ID | | `sttConfiguration` | `object` | Speech-to-text config | | `ttsConfiguration` | `object` | Text-to-speech config | ### Full Example with Voice ```typescript import { WiilClient } from 'wiil-js'; import { BusinessSupportServices, AgentRoleTemplateIdentifier, SupportedProprietor } from 'wiil-core-js'; const client = new WiilClient({ apiKey: process.env.WIIL_API_KEY! }); const result = await client.dynamicPhoneAgent.create({ // Required assistantName: 'Marcus', capabilities: [ BusinessSupportServices.APPOINTMENT_MANAGEMENT, BusinessSupportServices.PRODUCT_ORDER_MANAGEMENT ], // Optional - Role & Language role_template_identifier: AgentRoleTemplateIdentifier.CUSTOMER_SUPPORT_GENERAL, language: 'en-US', // Optional - Phone Configuration phoneConfigurationId: 'phone_config_123', // Optional - Voice Configuration sttConfiguration: { providerType: SupportedProprietor.DEEPGRAM, providerModelId: 'nova-2', languageId: 'en-US' }, ttsConfiguration: { providerType: SupportedProprietor.ELEVENLABS, providerModelId: 'eleven_turbo_v2', languageId: 'en-US', voiceId: 'voice_rachel' } }); console.log('Setup successful:', result.success); console.log('Phone number:', result.phoneNumber); console.log('Agent Config ID:', result.agentConfigurationId); console.log('Instruction Config ID:', result.instructionConfigurationId); ``` ### Result Type The `DynamicPhoneAgentSetupResult` includes: | Field | Type | Description | | ----- | ---- | ----------- | | `success` | `boolean` | Whether setup succeeded | | `agentConfigurationId` | `string` | Created agent config ID | | `instructionConfigurationId` | `string` | Created instruction config ID | | `phoneNumber` | `string` | Provisioned phone number | | `errorMessage` | `string?` | Error message if failed | | `metadata` | `object?` | Additional metadata | ### CRUD Operations ```typescript // Create const created = await client.dynamicPhoneAgent.create({ ... }); // Update (partial) const updated = await client.dynamicPhoneAgent.update({ id: 'agent_123', assistantName: 'Nathan' }); // Delete const deleted = await client.dynamicPhoneAgent.delete('agent_123'); ``` --- ## Web Agent Setup ### Overview The Dynamic Web Agent API provisions a web-based AI agent with integration snippets for website embedding. ### Required Fields | Field | Type | Description | | ----- | ---- | ----------- | | `assistantName` | `string` | Name of the AI assistant | | `websiteUrl` | `string` | URL of the website | | `capabilities` | `BusinessSupportServices[]` | Platform services enabled | ### Optional Fields | Field | Type | Description | | ----- | ---- | ----------- | | `communicationType` | `OttCommunicationType` | TEXT, VOICE, or UNIFIED (default: UNIFIED) | | `role_template_identifier` | `AgentRoleTemplateIdentifier` | Role/persona for the agent | | `language` | `string` | Language code (default: `"en"`) | | `instructionConfigurationId` | `string` | Existing instruction config | | `knowledgeSourceIds` | `string[]` | Knowledge sources | | `voice` | `string` | Voice ID | | `providerType` | `SupportedProprietor` | AI model provider | | `providerModelId` | `string` | Specific model ID | | `sttConfiguration` | `object` | Speech-to-text config | | `ttsConfiguration` | `object` | Text-to-speech config | ### Communication Types ```typescript import { OttCommunicationType } from 'wiil-core-js'; // Text-only chat communicationType: OttCommunicationType.TEXT // Voice-only interaction communicationType: OttCommunicationType.VOICE // Combined text and voice (default) communicationType: OttCommunicationType.UNIFIED ``` ### Full Example with Voice ```typescript import { WiilClient } from 'wiil-js'; import { BusinessSupportServices, AgentRoleTemplateIdentifier, OttCommunicationType, SupportedProprietor } from 'wiil-core-js'; const client = new WiilClient({ apiKey: process.env.WIIL_API_KEY! }); const result = await client.dynamicWebAgent.create({ // Required assistantName: 'Olivia', websiteUrl: 'https://example.com', capabilities: [BusinessSupportServices.APPOINTMENT_MANAGEMENT], // Optional - Communication Type communicationType: OttCommunicationType.UNIFIED, // Optional - Role & Language role_template_identifier: AgentRoleTemplateIdentifier.CUSTOMER_SUPPORT_GENERAL, language: 'en-US', // Optional - Voice Configuration sttConfiguration: { providerType: SupportedProprietor.DEEPGRAM, providerModelId: 'nova-2', languageId: 'en-US' }, ttsConfiguration: { providerType: SupportedProprietor.ELEVENLABS, providerModelId: 'eleven_turbo_v2', languageId: 'en-US', voiceId: 'voice_rachel' } }); console.log('Setup successful:', result.success); console.log('Agent Config ID:', result.agentConfigurationId); console.log('Integration snippets:'); result.integrationSnippets.forEach((snippet, i) => { console.log(` Snippet ${i + 1}:`, snippet); }); ``` ### Result Type The `DynamicWebAgentSetupResult` includes: | Field | Type | Description | | ----- | ---- | ----------- | | `success` | `boolean` | Whether setup succeeded | | `agentConfigurationId` | `string` | Created agent config ID | | `instructionConfigurationId` | `string` | Created instruction config ID | | `integrationSnippets` | `string[]` | Code snippets for embedding | | `errorMessage` | `string?` | Error message if failed | | `metadata` | `object?` | Additional metadata | ### Website Integration Use the returned integration snippets in your HTML: ```html