Set up an account from zero
The example is a dental clinic. Patients write to ask for a visit; the agent collects what the clinic needs, books the visit after a person approves it, and hands the case to a person when it should. Every step shows the same call by cURL, with the SDK and as an MCP tool call. The first conversation runs by API, so nothing reaches a real person.
The whole page is also a script you can run against the API: see Run it as a script.
The shape of the setup
| Step | You create | Reference |
|---|---|---|
| 1 | An API key and its scopes | API keys |
| 2 | A pipeline with stages, fields and an entry stage | Pipelines |
| 3 | An agent with a prompt, a model, skills and knowledge | Agents, Knowledge |
| 4 | Tools for the agent, with an approval | Actions and MCP, Approvals |
| 5 | The link between the entry stage and the agent | Pipelines |
| 6 | Channels: API, WhatsApp and email | WhatsApp, Email |
| 7 | Activation and the ready check | Agents |
| 8 | A webhook endpoint | Receive events |
| 9 | The first conversation | Inbox |
| 10 | Safety limits before customers write | Best practices, Usage and budgets |
1. An API key and its scopes
Create a key in the dashboard under Settings, Integrations. The secret is shown once. Give it these scopes and the site your action will call (https://example.com) as an allowed action origin.
Code
Expected: scopes lists the scopes above. GET /v2/scopes lists every scope a key can have and the scope catalog says what each one allows. A missing scope later answers 403 scope_missing with the scope in detail.
2. A pipeline with stages, fields and an entry stage
A pipeline is the path a conversation follows. Cases start in the stage marked entry. Create the pipeline with its stages in one call; the response lists the stage ids in order. Save them: you need the first for step 5 and the last for step 4.
Expected: 201 with status: "active" and stages holding three stg_ ids.
Now the fields. A field is a piece of data the case carries. The agent fills the ones with source: "agent"; instruction tells it what to ask for. A select carries its options, and a second select can depend on the first. sensitive hides a value from the agent and from webhooks.
A stage can ask for fields before a case enters it. Make "Booked" require the reason and the time, and add a quick reply your team can send from the inbox:
Expected: the stage answers with requiredFields set. Moving a case into "Booked" without those two fields answers 422 required_fields_missing. Details: Pipelines.
3. An agent from scratch
The agent needs a name, a prompt and a model. GET /v2/models lists the public model ids you can use, such as anthropic/claude-sonnet-5.5. Do not send provider: it comes from the model.
Write the prompt in a file. This one is complete: it says who the agent is, how it talks, what to collect, when to book and when to hand over.
Code
Create the agent with that file. It starts as a draft and only has the api channel for now.
Expected: 201 with status: "draft" and version: 1. Save the agt_ id.
Add a skill and a knowledge collection. A skill is know-how the agent loads only when the conversation needs it. A collection groups the documents the agent searches; give the agent the collection after you fill it.
Expected: the document comes back with status: "processing". It becomes ready in seconds, or failed with an error.code; the knowledge_document.ready and knowledge_document.failed events tell you (step 8). The agent finds the document only when it is ready. Read the status again with GET /v2/knowledge-collections/{id}/documents/{docId}. Details: Agents, Knowledge.
4. Tools: HTTP actions, MCP servers, grants and approval
An agent can only use the tools you grant it. Three kinds exist: an HTTP action of yours, a tool of an MCP server of yours, and Lelemon's own system tools (save_case_data, transfer_to_human, ask_team, and the WhatsApp interactive ones).
Register the action the prompt calls. The agent reads description to decide when to use it and fills input. The URL must be public, answer, and belong to a site allowed on your key (allowedActionOrigins).
variables are filled by Lelemon, never by the model. If your agent should call tools of an MCP server of yours, connect it and grant its tools the same way (see Actions and MCP):
The server must be a public Streamable HTTP MCP server that answers. Skip this call if you have none.
Now grant the tools. Granting is one tool at a time. book_appointment goes behind a person: with approval.mode: "always", the agent's call becomes an approval that waits, and only an approval runs the action. save_case_data writes the fields you list; transfer_to_human moves the case to the "Handoff" stage and writes the farewell the patient reads.
Expected: each grant answers granted: true. GET /v2/agents/{id}/tools lists the four tools as granted. Who decides the approvals, and how to decide them by API, is in Approve agent actions.
5. Link the agent to the entry stage
Cases enter a pipeline through its entry stage, so the agent that answers them belongs there.
Expected: the stage answers entry: true and your agentId.
6. Channels: API, WhatsApp and email
An agent answers only on the channels it lists. Add WhatsApp and email with PATCH, sending expectedVersion so two people cannot overwrite each other.
A WhatsApp connection returns a setupUrl for the owner of the number to finish. The number then answers with your agent. See WhatsApp.
Expected: status: "pending", then connected with a phoneNumberId (pn_...) once the owner finishes.
For email, add a sender domain you own. Set inboundAgentId so replies to that domain go to the agent. See Email.
Expected: status: "pending" with the DNS records to add, then verified once your DNS answers.
7. Activate and check ready
Activation turns the agent on. readiness.missing lists what still keeps people from reaching it, each with a code (no_stage, not_entry_stage or no_api_channel) and a message. An empty list means the agent is reachable. Add ?dryRun=true first to see the readiness without turning the agent on.
Expected: status: "active", readiness: { "ready": true, "missing": [] }. If ready is false, fix what missing says and activate again.
8. A webhook to hear about everything
Lelemon tells your server when something changes. Register one endpoint for the events this setup produces; "*" subscribes to every event type. The secret is shown once, so store it.
Your server verifies each delivery against the raw body with the endpoint secret:
Code
Expected: the test call makes a signed webhook_endpoint.test event arrive. The API accepts localhost, 127.0.0.1 and ::1 as the URL only when it runs with LELEMON_ALLOW_LOCAL_WEBHOOKS=true; otherwise use a public URL such as a tunnel. Details: Receive events, Verify signatures.
9. The first conversation
Create the contact, open a case in the pipeline and write as the contact. A message with author: "contact" makes the agent answer. PUT /v2/contacts/by-external-ref/{externalRef} creates the contact or updates it, so repeating the call never duplicates it.
Expected:
- The case opens in the entry stage with your agent (
stageId,agentId) andcontrol: "agent". - Your webhook receives
message.createdwithauthor: "agent". GET /v2/cases/{id}shows the fields the agent saved infields(reason,insurance,preferred_time,email).- When the patient confirms, the agent calls
book_appointmentand your webhook receivesapproval.requested. Decide it:
The key that approves must be named in the policy (approvers) and cannot be the one that opened the case. To use a key, name it as { "type": "key", "value": "key_..." } in step 4; otherwise an admin approves it in the dashboard.
10. Safety limits before customers write
- Turn on the recipient allowlist while you validate, so nothing reaches anyone outside your list.
- Set a monthly budget so a mistake cannot open conversations without limit.
Run it as a script
The folder apps/docs/examples/setup-from-zero holds a script that runs steps 1 to 5 and 7 to 9 on the api channel and checks the result of each. It reads the key from LELEMON_API_KEY, creates its data in your organization and removes the webhook endpoint at the end. Its README says how to run it.
What's next
- Run a campaign, message on events and schedule meetings once the agent answers.
- Read the guides for each resource: Agents, Pipelines, Contacts, Knowledge and API keys.
- Browse the use cases for complete setups by business type.