import { BoostGPT } from '@boostgpt/core-sdk';// Initialize clientconst client = new BoostGPT({ apiKey: process.env.BOOSTGPT_API_KEY});async function main() { // 1. Create a bot console.log('Creating bot...'); const botResult = await client.createBot({ name: 'Customer Support Assistant', model: 'gpt-4o', instruction: 'You are a helpful customer support agent. Be friendly and concise.' }); if (botResult.err) { console.error('Error creating bot:', botResult.err); return; } const botId = botResult.response.id; console.log('Bot created:', botId); // 2. Add training data console.log('\nAdding training data...'); const trainingResult = await client.startTraining({ bot_id: botId, type: 'text', source: ` Q: What are your business hours? A: We're open Monday-Friday, 9am-5pm EST. Q: How do I reset my password? A: Click "Forgot Password" on the login page and follow the instructions. Q: What's your return policy? A: We accept returns within 30 days of purchase. ` }); if (trainingResult.err) { console.error('Error adding training:', trainingResult.err); return; } console.log('Training queued:', trainingResult.response.id); // Wait for training to process console.log('Waiting for training to complete...'); await new Promise(resolve => setTimeout(resolve, 3000)); // 3. Chat with bot console.log('\nTesting bot...'); const chatResult = await client.chat({ bot_id: botId, message: 'What are your business hours?', chat_id: 'user-123' }); if (chatResult.err) { console.error('Error chatting:', chatResult.err); return; } console.log('Bot response:', chatResult.response);}main();
# Set API keyexport BOOSTGPT_API_KEY=your_api_key# Runnode basic-bot.js
Output:
Creating bot...Bot created: bot_abc123Adding training data...Training queued: source_xyz789Waiting for training to complete...Testing bot...Bot response: We're open Monday-Friday, 9am-5pm EST.