Learn how to create and manage prompts that can be used to generate content from your knowledge base with consistent instructions.

What are Prompts?

Prompts are reusable instructions that define how AI should interact with your content. They can include variables in {{variable}} format that get replaced when generating content.

Creating a Prompt

const API_URL = 'https://sdk.senso.ai/api/v1';
const API_KEY = 'YOUR_API_KEY';

async function createContentPrompt() {
  try {
    // Create a prompt for generating summaries
    const summaryResponse = await fetch(`${API_URL}/prompts`, {
      method: 'POST',
      headers: {
        'X-API-Key': API_KEY,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        name: 'Product Summary Generator',
        text: 'Based on the {{content_type}} information provided, create a concise summary that highlights the key features, benefits, and important details. Focus on making it accessible to {{audience}} and ensure the tone is {{tone}}.'
      })
    });
    
    const summaryPrompt = await summaryResponse.json();
    console.log('Summary prompt created:', summaryPrompt.prompt_id);

    // Create a prompt for FAQ generation
    const faqResponse = await fetch(`${API_URL}/prompts`, {
      method: 'POST',
      headers: {
        'X-API-Key': API_KEY,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        name: 'FAQ Generator',
        text: 'Analyze the {{content_type}} content and generate a comprehensive FAQ section. Create at least {{num_questions}} frequently asked questions with detailed answers. Ensure the questions address common concerns and the answers are clear and helpful.'
      })
    });
    
    const faqPrompt = await faqResponse.json();
    console.log('FAQ prompt created:', faqPrompt.prompt_id);
    
  } catch (error) {
    console.error('Error creating prompts:', error);
  }
}

createContentPrompt();

Managing Prompts

You can list, update, and delete prompts as needed:

// List all prompts
const promptsResponse = await fetch(`${API_URL}/prompts?limit=10`, {
  headers: { 'X-API-Key': API_KEY }
});
const prompts = await promptsResponse.json();
console.log('Available prompts:', prompts);

// Update a prompt
const updateResponse = await fetch(`${API_URL}/prompts/${promptId}`, {
  method: 'PUT',
  headers: {
    'X-API-Key': API_KEY,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Enhanced Product Summary Generator',
    text: 'Based on the {{content_type}} information provided, create a compelling summary that emphasizes {{focus_area}}. Include key features, benefits, and use cases. Make it suitable for {{audience}} with a {{tone}} tone.'
  })
});

const updatedPrompt = await updateResponse.json();

// Delete a prompt
await fetch(`${API_URL}/prompts/${promptId}`, {
  method: 'DELETE',
  headers: { 'X-API-Key': API_KEY }
});

Next Steps

Now that you’ve created prompts, you can: