SmartERP Documentation An Ashewa Technology Solutions Platform

The AI content workflow

Import the ai-content-generation workflow, connect it to Claude and to SmartERP.

The AI Content Generation workflow drafts a post's message and hashtags when someone presses Generate with AI. The file is n8n/workflows/ai-content-generation.json.

What it does#

NodeJob
WebhookReceives Odoo's request at the path social-media-generate-content (POST), and answers immediately.
Call Claude (Anthropic API)Sends the brief to Anthropic's Messages API and asks for JSON only: {"message": "…", "hashtags": ["…"]}.
Build Result PayloadParses the reply. If the call failed or the reply is not valid JSON, builds a failure payload instead.
Send Result to OdooPOSTs the result to the callback_url Odoo sent, with the shared key as X-Api-Key.

A Setup Notes sticky note in the workflow repeats the steps below.

Setup#

  1. Configure SmartERP first. Save the shared API key and, once you have it, the webhook URL (step 3):
    • Social Media Marketing Automation: Social Marketing → Configuration → Automation Settings.
    • AI Growth Workforce: the system parameters in System parameters.
  2. Import. In n8n, Workflows → Import from File, choose ai-content-generation.json.
  3. Activate the workflow, then copy the Webhook node's Production URL into SmartERP's n8n AI Content Webhook URL setting.
  4. Add the AI credential. Create an HTTP Header Auth credential named Anthropic API Key with the header name x-api-key and your Anthropic API key as the value. Attach it to the Call Claude node.

No credential is needed for the callback to SmartERP: the shared key arrives in the request body and the workflow sends it back.

Swap in any other AI provider or node if you prefer. Only the final Build Result Payload step has to keep producing {message, hashtags}.

Using it#

  1. Open a post and, optionally, fill AI Brief (what to write about). If you leave it empty, the AI works from the current message.
  2. Press Generate with AI. SmartERP shows "AI Content Requested" (AI Workforce) and sets the AI status to Requested.
  3. A few seconds later the post's message and hashtags are replaced and the status becomes Received.

Note

The draft replaces the message. It is a starting point for a person to review, not a published post. In the AI Growth Workforce it also sets AI Generated and writes an entry to the activity log saying a draft is ready for human review, and the post is still subject to the approval workflow.

Adapting it for the AI Growth Workforce#

The template builds its prompt from platform and account_handle, which the self-contained module sends. The AI Growth Workforce sends different fields:

The template readsThe AI Workforce sends instead
body.platformbody.platforms (a map: telegram, facebook, instagram, twitter)
body.account_handlebody.agent (the agent's name)
body.briefbody.brief (same)
body.callback_urlbody.callback_url (same)

Edit the prompt in the Call Claude node to use the fields you actually receive, for example listing the platforms whose flag is true. Left unchanged, the prompt would contain the word undefined in place of the platform and handle.

The callback works as-is: it posts {success, message, hashtags, error} to the callback_url, which the AI Workforce accepts, including hashtags as a list.

Troubleshooting#

SymptomLikely cause
"Configure the n8n AI webhook URL and shared API key first…"Settings missing. See step 1.
"Could not reach the n8n webhook…" or "Could not reach the AI workflow…"Wrong URL, workflow not active, or n8n unreachable from Odoo's server.
"AI workflow returned HTTP …"n8n answered with an error. Check the workflow's executions.
Status stays Requestedn8n could not call back: check web.base.url is your public address, and that the key matches.
Status becomes FailedThe AI call or the JSON parsing failed. AI Error / Error Message on the post shows why.
Last updated: 2026-10-16