0

Folder create agent

by
Published Nov 5, 2024

Create an agent in a folder, or in the home folder of a workspace.

Script taskade Verified

The script

Submitted by hugo697 Bun
Verified 581 days ago
1
//native
2
type Taskade = {
3
	token: string
4
}
5

6
export async function main(
7
	auth: Taskade,
8
	folderId: string,
9
	body: {
10
		name: string
11
		data:
12
			| {
13
					type: 'data'
14
					data: {
15
						commands: {
16
							name: string
17
							prompt: string
18
							id: string
19
							isBackgroundJob?: false | true
20
							searchToolEnabled?: false | true
21
							mode?: 'default' | 'plan-and-execute-v1' | 'plan-and-execute-v2'
22
						}[]
23
						description?: string
24
						persona?:
25
							| 'standup-comedian'
26
							| 'life-coach'
27
							| 'career-counselor'
28
							| 'nutritionist'
29
							| 'product-manager'
30
							| 'personal-trainer'
31
							| 'life-hacker'
32
							| 'travel-advisor'
33
							| 'mindfulness-coach'
34
							| 'financial-advisor'
35
							| 'language-tutor'
36
							| 'travel-guide'
37
							| 'marketing-expert'
38
							| 'software-developer'
39
							| 'diy-expert'
40
							| 'journalist'
41
							| 'tech-writer'
42
							| 'professional-chef'
43
							| 'professional-salesperson'
44
							| 'startup-tech-lawyer'
45
							| 'startup-idea-generator'
46
							| 'graphic-designer'
47
							| 'academic-researcher'
48
							| 'customer-support-agent'
49
							| 'hr-consultant'
50
							| 'entrepreneur'
51
							| 'ecommerce-strategist'
52
							| 'seo-expert'
53
							| 'programming-genius'
54
							| 'content-creator'
55
							| 'socialmedia-influencer'
56
							| 'investor'
57
							| 'pr-specialist'
58
							| 'business-mentor'
59
							| 'negotiator'
60
						tone?:
61
							| 'authoritative'
62
							| 'clinical'
63
							| 'cold'
64
							| 'confident'
65
							| 'cynical'
66
							| 'emotional'
67
							| 'empathetic'
68
							| 'formal'
69
							| 'friendly'
70
							| 'humourous'
71
							| 'informal'
72
							| 'ironic'
73
							| 'optimistic'
74
							| 'pessimistic'
75
							| 'playful'
76
							| 'sarcastic'
77
							| 'serious'
78
							| 'sympathetic'
79
							| 'tentative'
80
							| 'warm'
81
							| 'creative'
82
							| 'inspiring'
83
							| 'casual'
84
						avatar?: { type: 'emoji'; data: { value: string } }
85
						knowledgeEnabled?: false | true
86
					}
87
			  }
88
			| {
89
					type: 'template'
90
					template: {
91
						type:
92
							| 'Tasker'
93
							| 'Researcher'
94
							| 'Marketer'
95
							| 'EmailWriter'
96
							| 'Sales'
97
							| 'CustomerSupport'
98
							| 'ProjectManager'
99
							| 'ContentCreator'
100
							| 'Copywriter'
101
							| 'LegalAdvisor'
102
							| 'SeoSpecialist'
103
							| 'ProductivityCoach'
104
							| 'EngineeringExpert'
105
							| 'Translator'
106
							| 'Summarizer'
107
							| 'ResumeBuilder'
108
							| 'Storyteller'
109
							| 'Tutor'
110
							| 'BrandStrategist'
111
							| 'SocialMediaSpecialist'
112
							| 'BusinessStrategist'
113
							| 'FinancialAnalyst'
114
							| 'HumanResourcesManager'
115
							| 'DataScientist'
116
							| 'ITConsultant'
117
							| 'FinancialAdvisor'
118
							| 'HealthCoach'
119
							| 'SustainabilityConsultant'
120
							| 'UXDesigner'
121
							| 'QualityAssuranceAnalyst'
122
							| 'ProductManager'
123
							| 'GrowthHacker'
124
							| 'BusinessDevelopmentManager'
125
							| 'PublicRelationsSpecialist'
126
							| 'EventPlanner'
127
							| 'DataAnalyst'
128
							| 'Editor'
129
							| 'CEO'
130
							| 'InterviewCoach'
131
							| 'TechSupportAdvisor'
132
							| 'Doctor'
133
							| 'BlogExpert'
134
							| 'TweetOptimizer'
135
							| 'EmailMarketer'
136
							| 'CourseCreator'
137
							| 'ScriptCreator'
138
							| 'ScreenplayWriter'
139
							| 'Proofreader'
140
							| 'SalesColdEmailCoach'
141
							| 'CodeExplainer'
142
							| 'CreativeWritingCoach'
143
							| 'AdvertisingCopywriter'
144
							| 'VideoScriptWriter'
145
							| 'ProjectArchitect'
146
							| 'AICouncil'
147
							| 'Negotiator'
148
							| 'VCAssociate'
149
							| 'Books'
150
							| 'StartupMentor'
151
							| 'SmallBusiness'
152
							| 'WebDevelopment'
153
							| 'PromptEngineer'
154
							| 'ArticleWriter'
155
							| 'WorkflowAgent'
156
							| 'StrategyAgent'
157
							| 'ViralAgent'
158
							| 'SOPOnboardingAgent'
159
							| 'PressReleaseAgent'
160
						avatar?: { type: 'emoji'; data: { value: string } }
161
					}
162
			  }
163
	}
164
) {
165
	const url = new URL(`https://www.taskade.com/api/v1/folders/${folderId}/agents`)
166

167
	const response = await fetch(url, {
168
		method: 'POST',
169
		headers: {
170
			'Content-Type': 'application/json',
171
			Authorization: 'Bearer ' + auth.token
172
		},
173
		body: JSON.stringify(body)
174
	})
175

176
	if (!response.ok) {
177
		const text = await response.text()
178
		throw new Error(`${response.status} ${text}`)
179
	}
180

181
	return await response.json()
182
}
183