Create your first agent

Create an agent with instructions for answering your customers. Save changes in a draft and publish them when they are ready.

Before you start

Use your assistant connected to Platica or an API key stored in PLATIC_API_KEY.

In the platform: Create an agent with the creator.

  1. Create the agent

    Set the agent's name and instructions. Create an agent.

    import { Platic } from "platic-sdk";
    
    const platic = new Platic({ apiKey: process.env.PLATIC_API_KEY! });
    
    const agent = await platic.agents.create({
      name: "Sales",
      instructions: "You are the sales assistant for Acme. Answer kindly and briefly.",
    });

    Save the agent's id for the following calls. In cURL, assign it to AGENT_ID.

  2. Tune its instructions

    Edit the draft. The agent keeps using the published version while you prepare it. Update the draft.

    await platic.agents.draft.update(agent.id, {
      instructions: "You are the sales assistant for Acme. Answer in under 80 words. If you do not know a price, say so: never make it up.",
    });
  3. Publish

    Publish the draft to use the new instructions from the next message. Publish.

    await platic.agents.publish(agent.id);

Check it worked

Call Get the agent. The publication is ready when publication.versionId is set and hasUnpublishedChanges is false. Channels for receiving customer messages are connected separately.

Each save creates a version. See Versions and how to go back to restore an earlier one.

Next steps