The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Ask the onboarding CRM migration question with the ask_questions tool (#24214)
Raphaël Bosif4a280f4328a
diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/utils/__tests__/build-workspace-setup-prompt-text.util.spec.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/utils/__tests__/build-workspace-setup-prompt-text.util.spec.tsindex 0cf0a28763c..f85a42d53ab 100644--- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/utils/__tests__/build-workspace-setup-prompt-text.util.spec.ts+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/utils/__tests__/build-workspace-setup-prompt-text.util.spec.ts@@ -54,9 +54,8 @@ describe('buildWorkspaceSetupPromptText', () => {});expect(result).toContain('required ask_questions call');- expect(result).toContain('A written question does not count');expect(result).toContain(- 'a heading with nothing under it is not an ending',+ 'reply is unfinished until the ask_questions call is made',);expect(result).toContain('needs no skill and no learn_tools step');expect(result).toContain(@@ -121,6 +120,42 @@ describe('buildWorkspaceSetupPromptText', () => {},);+ it.each([+ ['a full enrichment', companyEnrichment],+ ['a null enrichment', null],+ ])(+ 'should make the migration-or-scratch question a tool call rather than text when %s is provided',+ (_label, enrichment) => {+ const result = buildWorkspaceSetupPromptText({+ companyEnrichment: enrichment,+ locale: 'en',+ });++ expect(result).toContain(+ 'Then stop writing and make the ask_questions call',+ );+ expect(result).toContain('its options');+ expect(result).toContain('never give that question a title of its own');+ expect(result).not.toContain('Close this reply with an ask_questions');+ },+ );++ it.each([+ ['a full enrichment', companyEnrichment],+ ['a null enrichment', null],+ ])(+ 'should leave an unlisted CRM to the free-text answer when %s is provided',+ (_label, enrichment) => {+ const result = buildWorkspaceSetupPromptText({+ companyEnrichment: enrichment,+ locale: 'en',+ });++ expect(result).toContain('leaving any other CRM to the free-text answer');+ expect(result).not.toContain('another CRM, and starting fresh');+ },+ );+it('should request the CRM export in plain text so the upload composer stays available', () => {const result = buildWorkspaceSetupPromptText({companyEnrichment,@@ -264,6 +299,17 @@ describe('buildWorkspaceSetupPromptText', () => {expect(result).toContain('Load a skill before proposing what it builds');});+ it('should name the plain-text question as the failure mode to avoid', () => {+ const result = buildWorkspaceSetupPromptText({+ companyEnrichment,+ locale: 'en',+ });++ expect(result).toContain(+ 'a question mark in your text means the call is missing',+ );+ });+it('should keep ask_questions options within the single-recommended limit', () => {const result = buildWorkspaceSetupPromptText({companyEnrichment,diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/utils/build-workspace-setup-prompt-text.util.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/utils/build-workspace-setup-prompt-text.util.tsindex e180564e8b8..06e1a30252d 100644--- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/utils/build-workspace-setup-prompt-text.util.ts+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/utils/build-workspace-setup-prompt-text.util.ts@@ -8,10 +8,10 @@ const NO_COMPANY_CONTEXT_LINE ='No information about the company that owns this workspace is available.';const FIRST_REPLY_INSTRUCTION_WITH_COMPANY_CONTEXT =- 'Do not greet them again, the page above already welcomed them by name. Open with one line saying you are an AI agent who will walk them through Twenty and set their workspace up with them, then a couple of lines on what you already know about their company, tailored to their business and specific enough to show you did your homework rather than reciting data points, written the way a colleague would rather than a form. When their job title is in your user context, say you see them doing that at the company and shape the setup around it; when it is missing, do not guess it. Invite them to correct anything. Close this reply with an ask_questions call asking whether they are moving over from another CRM or starting fresh, offering the two CRMs a company like theirs most likely uses, another CRM, and starting fresh. When they start fresh, present the data model proposal described below; when they name a CRM, follow the migration path below.';+ 'Do not greet them again, the page above already welcomed them by name. Open with one line saying you are an AI agent who will walk them through Twenty and set their workspace up with them, then a couple of lines on what you already know about their company, tailored to their business and specific enough to show you did your homework rather than reciting data points, written the way a colleague would rather than a form. When their job title is in your user context, say you see them doing that at the company and shape the setup around it; when it is missing, do not guess it. Invite them to correct anything. Then stop writing and make the ask_questions call: its question is whether they are moving over from another CRM or starting fresh, its options the two CRMs a company like theirs most likely uses and starting fresh, leaving any other CRM to the free-text answer. When they start fresh, present the data model proposal described below; when they name a CRM, follow the migration path below.';const FIRST_REPLY_INSTRUCTION_WITHOUT_COMPANY_CONTEXT =- 'You do not know what this company does yet. Do not greet them again, the page above already welcomed them by name. Open with one line saying you are an AI agent who will walk them through Twenty and set their workspace up with them. Close this reply with an ask_questions call asking whether they are moving over from another CRM or starting fresh, offering the two most widely used CRMs, another CRM, and starting fresh. When they name a CRM, follow the migration path below; when they start fresh, follow with one more ask_questions to learn what the business does, who its customers are, and what they want to use Twenty for, offering the most likely answers as options, and present the data model proposal described below once they answer.';+ 'You do not know what this company does yet. Do not greet them again, the page above already welcomed them by name. Open with one line saying you are an AI agent who will walk them through Twenty and set their workspace up with them. Then stop writing and make the ask_questions call: its question is whether they are moving over from another CRM or starting fresh, its options the two most widely used CRMs and starting fresh, leaving any other CRM to the free-text answer. When they name a CRM, follow the migration path below; when they start fresh, follow with one more ask_questions to learn what the business does, who its customers are, and what they want to use Twenty for, offering the most likely answers as options, and present the data model proposal described below once they answer.';export const buildWorkspaceSetupPromptText = ({companyEnrichment,@@ -44,7 +44,7 @@ Write your text first so it starts streaming immediately: before it, do not call${firstReplyInstruction}-A written question does not count, and a heading with nothing under it is not an ending: this reply is unfinished until the ask_questions call is made, so make it immediately after your last sentence.+This reply is unfinished until the ask_questions call is made. Ask it even though the answer seems obvious, and never give that question a title of its own.## Migrating from another CRM@@ -87,7 +87,7 @@ Twenty is new to this admin. Introduce a capability in one plain sentence beforeOpen each reply with a short plain title, and title each new step you move on to in the same reply. Write objects as chips every time you name them, including objects you have not created yet and Workflows and Dashboards themselves; fields and views become chips only after a tool returns their ids, and no reference renders inside a title.-Route decisions through ask_questions, not plain-text questions, with the one exception of the migration upload described above. Each takes 2 to 4 short options, at most one of them marked recommended, since a second one is rejected and the question is lost. The user can always answer in free text, so never spell the options out in your text.+Route decisions through ask_questions, not plain-text questions, with the one exception of the migration upload described above. Outside that exception, a question mark in your text means the call is missing. Each takes 2 to 4 short options, at most one of them marked recommended, since a second one is rejected and the question is lost. The user can always answer in free text, so never spell the options out in your text.When creating objects and fields, their names must be in English (camelCase field names, singular English object names), while every user-facing label (labelSingular, labelPlural, field labels, select option labels) must be in the user's language.