| 1 |
import { canvasView } from '@agent/lib/canvas-views'; |
| 2 |
import { DemoForm } from '@agent/workflows/canvas/components/DemoForm'; |
| 3 |
import { |
| 4 |
nextDemoFormStep, |
| 5 |
updateDemoForm, |
| 6 |
} from '@agent/workflows/canvas/components/demo-form-tools'; |
| 7 |
import { __ } from '@wordpress/i18n'; |
| 8 |
|
| 9 |
// Views that dim the chat can't deliver on an offer to help fill the form. |
| 10 |
const reply = (canvas) => |
| 11 |
canvasView(canvas)?.assist |
| 12 |
? // translators: The agent has just opened a three-step form the user fills in. |
| 13 |
__( |
| 14 |
"I've opened the demo form for you to fill out. There are three steps. Feel free to ask me any questions or if you need help filling it out.", |
| 15 |
'extendify-local', |
| 16 |
) |
| 17 |
: // translators: The agent has just opened a three-step form the user fills in. |
| 18 |
__( |
| 19 |
"I've opened the demo form for you to fill out. There are three steps.", |
| 20 |
'extendify-local', |
| 21 |
); |
| 22 |
|
| 23 |
export const demoFormWorkflow = ({ id, canvas, icon, text }) => ({ |
| 24 |
// Nothing to save, so partners never see it. |
| 25 |
available: () => Boolean(window.extSharedData.devbuild), |
| 26 |
id, |
| 27 |
icon, |
| 28 |
abilities: [ |
| 29 |
'extendify/site-info', |
| 30 |
'extendify/content-list', |
| 31 |
'extendify/content-search', |
| 32 |
'extendify/content-read', |
| 33 |
'extendify/options', |
| 34 |
'extendify/taxonomies', |
| 35 |
'extendify/media', |
| 36 |
'extendify/navigation', |
| 37 |
'extendify/theme-settings', |
| 38 |
updateDemoForm, |
| 39 |
nextDemoFormStep, |
| 40 |
], |
| 41 |
whenFinished: { component: DemoForm, canvas }, |
| 42 |
example: { |
| 43 |
text, |
| 44 |
agentResponse: { |
| 45 |
reply: reply(canvas), |
| 46 |
// The three share a tool id: one form, and only assisted reaches the backend. |
| 47 |
whenFinishedTool: { |
| 48 |
id: 'demo-form', |
| 49 |
labels: { |
| 50 |
confirm: __('Submitted the demo form', 'extendify-local'), |
| 51 |
cancel: __('Closed the demo form', 'extendify-local'), |
| 52 |
}, |
| 53 |
}, |
| 54 |
}, |
| 55 |
}, |
| 56 |
}); |
| 57 |
|