// Install the SDKnpm install stateset-node// Create your agent (agent.js)import { StateSetClient } from 'stateset-node';const client = new StateSetClient({ apiKey: 'your_api_key_here' // Get from dashboard});async function deployAgent() { const agent = await client.agents.create({ name: 'Alex', role: 'Customer Success Specialist', personality: 'Friendly, helpful, and solution-oriented', greeting: 'Hi! I\'m Alex from customer success. How can I help you today?', capabilities: [ 'answer_product_questions', 'track_orders', 'process_returns', 'technical_support' ] }); console.log(`Agent deployed! ID: ${agent.id}`); console.log(`Chat URL: https://app.stateset.com/chat/${agent.id}`);}deployAgent();
# Send a message via APIcurl -X POST https://api.stateset.com/v1/chat \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "agent_id": "agent_xxx", "message": "Hello, I need help with my order", "session_id": "test_session_001" }'# Response{ "response": "I'd be happy to help you with your order! Could you please provide your order number or email address so I can look that up for you?", "confidence": 0.98, "suggested_actions": ["lookup_order", "check_status"], "session_id": "test_session_001"}
Make your agent smarter with your business knowledge:
Copy
Ask AI
// Upload your documentationconst kb = await client.knowledgeBase.create({ name: 'Product Documentation', agent_id: agent.id});await kb.uploadDocument('./product-guide.pdf');await kb.uploadDocument('./faq.md');// Your agent now knows everything in these docs!
// Connect to your order systemawait agent.addIntegration({ type: 'webhook', name: 'order_lookup', endpoint: 'https://api.yourstore.com/orders', authentication: { type: 'api_key', key: process.env.STORE_API_KEY }});// Now your agent can actually look up orders!
<!-- Add to your website --><script src="https://cdn.stateset.com/widget.js"></script><script> StateSet.init({ agentId: 'agent_xxx', position: 'bottom-right', primaryColor: '#6366f1', greeting: 'Hi! How can I help you today?' });</script>