PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 8.7.7
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v8.7.7
8.7.7 8.7.6 8.7.5 8.7.4 8.7.3 8.7.2 8.7.1 8.7.0 8.6.9 8.6.8 8.6.7 8.6.6 8.6.5 8.6.4 8.6.2 8.6.1 8.6.0 8.5.9 8.5.8 8.5.7 8.5.6 8.5.5 8.5.4 8.5.3 8.5.2 All 533 releases
chatbot / addons / automator / includes / core / default-workflows.php

default-workflows.php in WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services 8.7.7, at addons/automator/includes/core/default-workflows.php

331 lines 8.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Default Workflows Installer
4 *
5 * @package WPbot_Automator
6 */
7
8 namespace WPbot_Automator\Core;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 }
13
14 /**
15 * Default_Workflows class
16 */
17 class Default_Workflows {
18
19 /**
20 * Install default workflows
21 */
22 public static function install() {
23 global $wpdb;
24 $table = Database::get_workflows_table();
25
26 // Check if any workflows exist.
27 $count = $wpdb->get_var( "SELECT COUNT(*) FROM {$table}" );
28
29 if ( intval( $count ) > 0 ) {
30 return; // Workflows already exist, do not overwrite.
31 }
32
33 // Define default workflows.
34 $workflows = self::get_defaults();
35
36 foreach ( $workflows as $workflow ) {
37 $wpdb->insert(
38 $table,
39 array(
40 'name' => $workflow['name'],
41 'description' => $workflow['description'],
42 'workflow_data' => wp_json_encode( $workflow['workflow_data'] ),
43 'status' => 'active',
44 ),
45 array( '%s', '%s', '%s', '%s' )
46 );
47 }
48 }
49
50 /**
51 * Get default workflow data
52 *
53 * @return array
54 */
55 private static function get_defaults() {
56 return array(
57 array(
58 'name' => 'Contact form to google sheet',
59 'description' => 'Submit contact form data to a google sheet.',
60 'workflow_data' => array(
61 'nodes' => array(
62 array(
63 'id' => 'trigger-1',
64 'type' => 'trigger',
65 'position' => array(
66 'x' => 100,
67 'y' => 100,
68 ),
69 'data' => array(
70 'appId' => 'cf7',
71 'actionId' => 'cf7_submit',
72 'label' => 'Contact form submitted',
73 ),
74 ),
75 array(
76 'id' => 'action-1',
77 'type' => 'action',
78 'position' => array(
79 'x' => 500,
80 'y' => 100,
81 ),
82 'data' => array(
83 'appId' => 'google_sheets',
84 'actionId' => 'add_row',
85 'label' => 'Add row to Google Sheet',
86 'config' => array(
87 'sheet_id' => 'your_google_sheet_id_here',
88 'worksheet' => 'Sheet1',
89 'row_data' => array(
90 '{field_name_1}',
91 '{field_name_2}',
92 '{field_name_3}',
93 ),
94 ),
95 ),
96 ),
97 ),
98 'connections' => array(
99 array(
100 'id' => 'conn-1',
101 'source' => 'trigger-1',
102 'target' => 'action-1',
103 ),
104 ),
105 ),
106 ),
107 array(
108 'name' => 'WPBot Session to Google Sheet',
109 'description' => 'Automatically save WPBot chat session details (Name, Email, Phone) to a Google Sheet.',
110 'workflow_data' => array(
111 'nodes' => array(
112 array(
113 'id' => 'trigger-1',
114 'type' => 'trigger',
115 'position' => array(
116 'x' => 100,
117 'y' => 100,
118 ),
119 'data' => array(
120 'appId' => 'wpbot',
121 'actionId' => 'wpbot_chat_session_saved',
122 'label' => 'WPBot Chat Session Saved',
123 ),
124 ),
125 array(
126 'id' => 'action-1',
127 'type' => 'action',
128 'position' => array(
129 'x' => 500,
130 'y' => 100,
131 ),
132 'data' => array(
133 'appId' => 'google_sheets',
134 'actionId' => 'add_row',
135 'label' => 'Add row to Google Sheet',
136 'config' => array(
137 'sheet_id' => 'your_google_sheet_id_here',
138 'worksheet' => 'Sheet1',
139 'row_data' => array(
140 '{{wpbot.wpbot_chat_session_saved.session_id}}',
141 '{{wpbot.wpbot_chat_session_saved.name}}',
142 '{{wpbot.wpbot_chat_session_saved.email}}',
143 '{{wpbot.wpbot_chat_session_saved.phone}}',
144 ),
145 ),
146 ),
147 ),
148 ),
149 'connections' => array(
150 array(
151 'id' => 'conn-1',
152 'source' => 'trigger-1',
153 'target' => 'action-1',
154 ),
155 ),
156 ),
157 ),
158 array(
159 'name' => 'WPBot AI Email Extractor to Google Sheets',
160 'description' => 'Chat sessions are sent to AI for analysis to extract email addresses, which are then saved in a Google Sheet.',
161 'workflow_data' => array(
162 'nodes' => array(
163 array(
164 'id' => 'trigger-1',
165 'type' => 'trigger',
166 'position' => array(
167 'x' => 100,
168 'y' => 100,
169 ),
170 'data' => array(
171 'appId' => 'wpbot',
172 'actionId' => 'wpbot_chat_session_saved',
173 'label' => 'WPBot Chat Session Saved',
174 ),
175 ),
176 array(
177 'id' => 'action-1',
178 'type' => 'action',
179 'position' => array(
180 'x' => 420,
181 'y' => 100,
182 ),
183 'data' => array(
184 'appId' => 'openai',
185 'actionId' => 'chat_completion',
186 'label' => 'Extract Emails',
187 'config' => array(
188 'model' => 'gpt-4o-mini',
189 'prompt' => "Extract any email addresses from the following chat transcript. If none are found, return 'No Email'. Return ONLY the email addresses comma-separated, with no other text.\n\nTranscript: {{wpbot.wpbot_chat_session_saved.conversation}}",
190 'max_tokens' => '100',
191 'temperature' => '0.1',
192 ),
193 ),
194 ),
195 array(
196 'id' => 'action-2',
197 'type' => 'action',
198 'position' => array(
199 'x' => 740,
200 'y' => 100,
201 ),
202 'data' => array(
203 'appId' => 'google_sheets',
204 'actionId' => 'add_row',
205 'label' => 'Add row to Google Sheet',
206 'config' => array(
207 'sheet_id' => 'your_google_sheet_id_here',
208 'worksheet' => 'Sheet1',
209 'row_data' => array(
210 '{{wpbot.wpbot_chat_session_saved.session_id}}',
211 '{{openai.chat_completion.response}}',
212 ),
213 ),
214 ),
215 ),
216 ),
217 'connections' => array(
218 array(
219 'id' => 'conn-1',
220 'source' => 'trigger-1',
221 'target' => 'action-1',
222 ),
223 array(
224 'id' => 'conn-2',
225 'source' => 'action-1',
226 'target' => 'action-2',
227 ),
228 ),
229 ),
230 ),
231 array(
232 'name' => 'Conversational Form to Sheet, AI & Email',
233 'description' => 'Saves conversational form data to Google Sheets, generates an AI summary, and emails the response.',
234 'workflow_data' => array(
235 'nodes' => array(
236 array(
237 'id' => 'trigger-1',
238 'type' => 'trigger',
239 'position' => array(
240 'x' => 100,
241 'y' => 100,
242 ),
243 'data' => array(
244 'appId' => 'wpbot',
245 'actionId' => 'conversationalforms_submit',
246 'label' => 'Conversational Forms Submitted',
247 ),
248 ),
249 array(
250 'id' => 'action-1',
251 'type' => 'action',
252 'position' => array(
253 'x' => 400,
254 'y' => 100,
255 ),
256 'data' => array(
257 'appId' => 'google_sheets',
258 'actionId' => 'add_row',
259 'label' => 'Add row to Google Sheet',
260 'config' => array(
261 'sheet_id' => 'your_google_sheet_id_here',
262 'worksheet' => 'Sheet1',
263 'row_data' => array(
264 '{{wpbot.conversationalforms_submit.name}}',
265 '{{wpbot.conversationalforms_submit.email}}',
266 ),
267 ),
268 ),
269 ),
270 array(
271 'id' => 'action-2',
272 'type' => 'action',
273 'position' => array(
274 'x' => 700,
275 'y' => 100,
276 ),
277 'data' => array(
278 'appId' => 'openai',
279 'actionId' => 'chat_completion',
280 'label' => 'Generate Summary',
281 'config' => array(
282 'model' => 'gpt-4o-mini',
283 'prompt' => "Summarize the following form submission: Name: {{wpbot.conversationalforms_submit.name}}, Email: {{wpbot.conversationalforms_submit.email}}",
284 'max_tokens' => '150',
285 'temperature' => '0.7',
286 ),
287 ),
288 ),
289 array(
290 'id' => 'action-3',
291 'type' => 'action',
292 'position' => array(
293 'x' => 1000,
294 'y' => 100,
295 ),
296 'data' => array(
297 'appId' => 'mail',
298 'actionId' => 'send_email',
299 'label' => 'Send Email Response',
300 'config' => array(
301 'to_email' => '{{wpbot.conversationalforms_submit.email}}',
302 'subject' => 'Thank you for your submission',
303 'body' => "Hello {{wpbot.conversationalforms_submit.name}},\n\nHere is a summary of your submission:\n{{openai.chat_completion.response}}",
304 'is_html' => false,
305 ),
306 ),
307 ),
308 ),
309 'connections' => array(
310 array(
311 'id' => 'conn-1',
312 'source' => 'trigger-1',
313 'target' => 'action-1',
314 ),
315 array(
316 'id' => 'conn-2',
317 'source' => 'action-1',
318 'target' => 'action-2',
319 ),
320 array(
321 'id' => 'conn-3',
322 'source' => 'action-2',
323 'target' => 'action-3',
324 ),
325 ),
326 ),
327 ),
328 );
329 }
330 }
331