-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-agent.js
More file actions
79 lines (65 loc) · 1.97 KB
/
Copy pathcreate-agent.js
File metadata and controls
79 lines (65 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* AutoManus API - Create Agent Example (Node.js)
*
* Creates an AI sales agent and deploys it to WhatsApp + Webchat.
*
* Usage:
* node create-agent.js
*
* Environment variables:
* AUTOMANUS_API_KEY - Optional. If provided, agent is created under your account.
*/
const API_URL = 'https://automanus.io/api/v1/public/agents';
async function createAgent() {
// Your details
const email = 'you@company.com';
const companyName = 'Acme Corp';
const websiteUrl = 'https://acme.com';
// Optional: Use API key for authenticated requests
const apiKey = process.env.AUTOMANUS_API_KEY;
const headers = {
'Content-Type': 'application/json',
};
if (apiKey) {
headers['Authorization'] = `Bearer ${apiKey}`;
}
try {
const response = await fetch(API_URL, {
method: 'POST',
headers,
body: JSON.stringify({
email,
company_name: companyName,
website_url: websiteUrl,
}),
});
const data = await response.json();
if (!response.ok) {
console.error('Error:', data.error || 'Failed to create agent');
return;
}
console.log('Agent created successfully!\n');
console.log('Agent ID:', data.agent_id);
console.log('Agent Name:', data.agent_name);
console.log('Company:', data.company_name);
console.log('\n--- Deployment Info ---');
console.log('WhatsApp Link:', data.whatsapp_link);
console.log('Knowledge Base Items:', data.knowledge_base_count);
if (data.webchat_embed_code) {
console.log('\n--- Webchat Embed Code ---');
console.log(data.webchat_embed_code);
}
if (data.claim_url) {
console.log('\n--- Claim Your Agent ---');
console.log('Check your email for the magic link, or visit:');
console.log(data.claim_url);
}
if (data.dashboard_url) {
console.log('\n--- Dashboard ---');
console.log(data.dashboard_url);
}
} catch (error) {
console.error('Request failed:', error.message);
}
}
createAgent();