pollax 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,234 @@
1
+ # Pollax TypeScript/JavaScript SDK
2
+
3
+ Official TypeScript/JavaScript SDK for the Pollax AI Voice Platform.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @pollax/sdk
9
+ # or
10
+ yarn add @pollax/sdk
11
+ # or
12
+ pnpm add @pollax/sdk
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import Pollax from '@pollax/sdk';
19
+
20
+ const pollax = new Pollax({
21
+ apiKey: 'sk_live_your_api_key_here',
22
+ });
23
+
24
+ // Create an AI agent
25
+ const agent = await pollax.agents.create({
26
+ name: 'Customer Support Agent',
27
+ systemPrompt: 'You are a helpful customer support agent for Acme Corp.',
28
+ voice_id: 'alloy',
29
+ model: 'gpt-4',
30
+ });
31
+
32
+ // Make a call
33
+ const call = await pollax.calls.create({
34
+ agent_id: agent.id,
35
+ to_number: '+1234567890',
36
+ from_number: '+0987654321',
37
+ });
38
+
39
+ console.log(`Call initiated: ${call.callSid}`);
40
+ ```
41
+
42
+ ## Features
43
+
44
+ - Full TypeScript support with complete type definitions
45
+ - Promise-based async/await API
46
+ - Automatic retry logic with exponential backoff
47
+ - Comprehensive error handling
48
+ - Works in Node.js and modern browsers
49
+ - Tree-shakeable ESM and CommonJS builds
50
+
51
+ ## API Reference
52
+
53
+ ### Client Initialization
54
+
55
+ ```typescript
56
+ const pollax = new Pollax({
57
+ apiKey: 'sk_live_...', // Required
58
+ baseURL: 'https://api.pollax.ai', // Optional
59
+ timeout: 30000, // Optional (ms)
60
+ maxRetries: 3, // Optional
61
+ tenantId: 'org_123', // Optional
62
+ });
63
+ ```
64
+
65
+ ### Agents
66
+
67
+ ```typescript
68
+ // Create agent
69
+ const agent = await pollax.agents.create({
70
+ name: 'Support Agent',
71
+ system_prompt: 'You are a helpful assistant',
72
+ voice_provider: 'elevenlabs',
73
+ voice_id: 'voice_abc123',
74
+ model: 'gpt-4',
75
+ });
76
+
77
+ // List agents
78
+ const agents = await pollax.agents.list({ is_active: true });
79
+
80
+ // Get agent
81
+ const agent = await pollax.agents.retrieve('agent_123');
82
+
83
+ // Update agent
84
+ const updated = await pollax.agents.update('agent_123', {
85
+ name: 'New Name',
86
+ is_active: false,
87
+ });
88
+
89
+ // Delete agent
90
+ await pollax.agents.delete('agent_123');
91
+ ```
92
+
93
+ ### Calls
94
+
95
+ ```typescript
96
+ // Create call
97
+ const call = await pollax.calls.create({
98
+ agent_id: 'agent_123',
99
+ to_number: '+1234567890',
100
+ from_number: '+0987654321',
101
+ metadata: {
102
+ customer_id: 'cust_456',
103
+ },
104
+ });
105
+
106
+ // List calls
107
+ const calls = await pollax.calls.list({
108
+ agent_id: 'agent_123',
109
+ status: 'completed',
110
+ });
111
+
112
+ // Get call
113
+ const call = await pollax.calls.retrieve('CA123456');
114
+
115
+ // End call
116
+ await pollax.calls.end('CA123456');
117
+
118
+ // Get transcript
119
+ const transcript = await pollax.calls.getTranscript('CA123456');
120
+ ```
121
+
122
+ ### Campaigns
123
+
124
+ ```typescript
125
+ // Create campaign
126
+ const campaign = await pollax.campaigns.create({
127
+ name: 'Q1 Outreach',
128
+ agent_id: 'agent_123',
129
+ contacts: [
130
+ { name: 'John', phone: '+1234567890' },
131
+ { name: 'Jane', phone: '+0987654321' },
132
+ ],
133
+ });
134
+
135
+ // Start campaign
136
+ await pollax.campaigns.start('campaign_123');
137
+
138
+ // Get stats
139
+ const stats = await pollax.campaigns.getStats('campaign_123');
140
+ ```
141
+
142
+ ### Knowledge Base
143
+
144
+ ```typescript
145
+ // Upload document
146
+ const doc = await pollax.knowledge.upload({
147
+ name: 'Product Manual',
148
+ file: pdfFile,
149
+ type: 'pdf',
150
+ });
151
+
152
+ // Search knowledge
153
+ const results = await pollax.knowledge.search({
154
+ query: 'How do I reset password?',
155
+ limit: 5,
156
+ });
157
+ ```
158
+
159
+ ### Analytics
160
+
161
+ ```typescript
162
+ // Get dashboard stats
163
+ const stats = await pollax.analytics.getStats();
164
+
165
+ // Get call volume
166
+ const volume = await pollax.analytics.getCallVolume({
167
+ period: '7d',
168
+ });
169
+
170
+ // Get agent performance
171
+ const performance = await pollax.analytics.getAgentPerformance('agent_123');
172
+ ```
173
+
174
+ ## Error Handling
175
+
176
+ ```typescript
177
+ import { PollaxError, AuthenticationError, NotFoundError } from '@pollax/sdk';
178
+
179
+ try {
180
+ const agent = await pollax.agents.retrieve('agent_123');
181
+ } catch (error) {
182
+ if (error instanceof AuthenticationError) {
183
+ console.error('Invalid API key');
184
+ } else if (error instanceof NotFoundError) {
185
+ console.error('Agent not found');
186
+ } else if (error instanceof PollaxError) {
187
+ console.error(`API error: ${error.message}`);
188
+ console.error(`Status code: ${error.statusCode}`);
189
+ }
190
+ }
191
+ ```
192
+
193
+ ## TypeScript Support
194
+
195
+ The SDK is written in TypeScript and provides complete type definitions:
196
+
197
+ ```typescript
198
+ import Pollax, { Agent, Call, Campaign } from '@pollax/sdk';
199
+
200
+ const pollax = new Pollax({ apiKey: 'sk_live_...' });
201
+
202
+ // Full type safety
203
+ const agent: Agent = await pollax.agents.create({
204
+ name: 'Support Agent',
205
+ system_prompt: 'You are helpful',
206
+ model: 'gpt-4', // TypeScript knows valid values
207
+ });
208
+
209
+ const call: Call = await pollax.calls.create({
210
+ agent_id: agent.id,
211
+ to_number: '+1234567890',
212
+ });
213
+ ```
214
+
215
+ ## Browser Usage
216
+
217
+ The SDK works in modern browsers with module bundlers:
218
+
219
+ ```html
220
+ <script type="module">
221
+ import Pollax from '@pollax/sdk';
222
+
223
+ const pollax = new Pollax({
224
+ apiKey: 'sk_live_...',
225
+ });
226
+
227
+ const agents = await pollax.agents.list();
228
+ console.log(agents);
229
+ </script>
230
+ ```
231
+
232
+ ## License
233
+
234
+ MIT