Skip to main content

Step 6 — AI assistant and a daily job

Two additions: the AI assistant, so that users ask questions in plain language, and a Nomaflow job that flags the deals left without news and tells the sales team.


At a glance​

AI AssistantWhich deals are in negotiation?sql_query · crm.deals_get1 deal: Logistics platform —Beta SARL, 120 000.crm-stalled-deals0 8 ∗ ∗ 0-4SUCCEEDED● onRun now🔔 Notifications2 deals without news for 14 daysRead queries onlywith the user's scopeDaily job08:00, Monday to FridayNotification ruleon succeeded, {ROWS}

The AI assistant​

Settings​

Liberty Next → Administer → App → AI Assistant: Enabled, the Anthropic API key, the Model, and Allowed connectors crm. Save. See AI assistant.

Access​

In the crm-sales role, Beyond the menus: Allow — AI assistant. Save. Bob now has an Assistant button at the top right.

Descriptions​

The assistant chooses among the queries from their label and description. On the CRM's read queries (Advanced tab of the query editor), write two sentences — what the rows are, which questions they answer:

QueryDescription
customers_getCustomers with industry, country, status and e-mail. For questions about the customer base.
deals_getDeals with customer, stage, amount and expected close date. For pipeline questions.
pipeline_by_stage_getOpen amount per pipeline stage. For pipeline breakdown questions.

Try it​

As Bob: Which deals are in negotiation? — What is the open amount per stage? — Which customers have no deal?

The assistant runs read queries only, with Bob's rights and data scope: it sees the French customers only, and it never changes data. See Expose data to the AI assistant.


A daily job — stalled deals​

A deal without any update for 14 days is flagged, and the sales team gets a notification.

The query​

Add a stalled column to deals, then a writable query flag_stalled_deals:

ALTER TABLE deals ADD stalled VARCHAR(1) DEFAULT 'N';
UPDATE deals SET STALLED = 'Y'
WHERE STAGE NOT IN ('WON', 'LOST')
AND COALESCE(UPDATED_AT, CURRENT_TIMESTAMP - INTERVAL '30' DAY) < CURRENT_TIMESTAMP - INTERVAL '14' DAY
AND STALLED = 'N'

Add STALLED = 'N' to deals_put so that any change to a deal clears the flag.

The job​

Nomaflow → Jobs → + New job:

FieldValue
Idcrm-stalled-deals
DescriptionFlags deals without news for 14 days.
Schedule0 8 * * 0-4 — 08:00, Monday to Friday (day 0 is Monday)
TimezoneEurope/Paris
StepAdd step: sql_query, name flag-stalled, connector crm, query flag_stalled_deals.
AlertsSend alerts, On failure, recipients user:<your user>.

Save, then Run with parameters to run it once: the run detail shows the rows updated. See Create a job.

The notification​

Liberty Next → Build → Notifications, a rule:

FieldValue
TriggerA job event — job crm-stalled-deals, event succeeded.
Channelsportal
Recipientsrole:crm-sales
Subject{ROWS} deals without news for 14 days

The sales team finds it in the bell every morning. A STALLED filter on the Deals screen lists them. See Notifications.


What you have now​

A complete CRM built from Settings:

  • Screens — Customers, Deals, and the Activities of each deal.
  • A dashboard — the pipeline with KPIs, a chart and the latest activities.
  • Roles — read-only and sales, with a data scope by country, and company sign-in.
  • An AI assistant over the CRM's queries, within each user's rights.
  • A daily job that flags stalled deals, with a notification.

The only code written is SQL.


Where to go from here​

You want to…Read
Apply the pattern to another database or ERPWhat you can build
Put the CRM in productionProduction
Move it to another environmentPackages
Find a specific recipeCookbook