Updating System Prompts via API
# support
m
We need a dynamic system prompt where data updates in real-time. For example, when a new product is added to a CRM, the system prompt should reflect this change—either by replacing the full payload or appending only the new product details (e.g., name, description, price, etc.). Is this possible? If so, what is the recommended approach? Thanks in advance! 🙏🏻
k
To implement dynamic system prompts that update in real-time. There are two recommended approaches to achieve this: 1\. Using the Add Message API (Recommended) You can use the Add Message API to dynamically update the conversation by sending a system message. Here's how:
Copy code
// Send a system message with updated product info

const message = {
  type: 'add-message',
  message: {
    role: 'system',
    content: Updated product catalog: ${JSON.stringify(products)},
  },
  // Set to false to silently update without triggering a response
  triggerResponseEnabled: false  
};
2\. Using Variable Substitution You can use variable substitution in your system prompts and update them dynamically:
Copy code
const assistant = {
  model: {
    messages: [
      {
        role: 'system',
        content: 'Current products: {{products}}'
      }
    ]
  }
};

// Update variables
const variables = {
  products: JSON.stringify(updatedProducts)
};
Both methods allow for dynamic updates during an active conversation. You can choose between triggering a new response or silently updating the context. FYI: Changes are properly tracked in the conversation history and updates are handled efficiently without requiring full context reloads
10 Views