> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openhermit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Prompts

> Control exactly what AI agents do before, during, and after each action.

Agent prompts are the most powerful feature in OpenHermit. They let you guide AI agents through your actions — providing context before they act, confirming success, handling failures, and chaining to next steps.

## The three prompts

Navigate to **Actions → Edit Prompts** for any detected action.

### Before Prompt

Shown to the agent *before* it attempts the action. Use this to tell the agent what information it needs to collect from the user first.

```
Before Prompt example:
"Please confirm you have the customer's full name, email address, 
and a clear description of their question before submitting this form."
```

**When to use it:**

* Your form requires specific data the agent might not have ready
* You want to prevent incomplete or low-quality submissions
* You need the agent to set expectations with the user before proceeding

***

### Success Prompt

Returned to the agent after the action completes successfully. Use this to confirm what happens next and guide the agent's response to the user.

```
Success Prompt example:
"The contact form was submitted successfully. Our team responds 
within 24 business hours. If this is urgent, the customer can also 
book a direct meeting at calendly.com/yourname/30min"
```

**When to use it:**

* Tell agents realistic response timeframes
* Offer alternative contact methods for urgent cases
* Chain to the next best action (booking, payment, etc.)

***

### Failure Prompt

Returned if the action fails (form validation error, network issue, etc.). Prevents agents from leaving users stuck.

```
Failure Prompt example:
"The form could not be submitted. Please ask the customer to try 
again, or offer them our direct email: hello@example.com or 
phone: +41 44 123 4567"
```

***

### Next Action URL + Label

After a successful action, you can chain agents directly to the next step. This appears in the manifest and gets injected as a suggested next action.

| Field             | Example                               |
| ----------------- | ------------------------------------- |
| Next Action URL   | `https://calendly.com/yourname/30min` |
| Next Action Label | `Book a 30-minute meeting`            |

***

## How prompts reach agents

Prompts are delivered in two ways simultaneously:

**1. Via the manifest** (`/.well-known/webmcp.json`)

```json theme={null}
{
  "actions": [
    {
      "name": "contact_form",
      "tool_name": "contact_form",
      "before_prompt": "Please have name and email ready...",
      "success_prompt": "Form submitted. We reply within 24h...",
      "failure_prompt": "Try our direct email...",
      "next_action": {
        "url": "https://calendly.com/...",
        "label": "Book a meeting"
      }
    }
  ]
}
```

**2. Injected into the page DOM**

The script adds a hidden element to each page with your prompts, so agents reading the live DOM can also see them:

```html theme={null}
<div 
  aria-label="WebMCP Agent Instructions" 
  style="position:absolute;left:-9999px;"
>
  Before: Please have name and email ready...
  Success: Form submitted. We reply within 24h...
</div>
```

***

## Prompt writing tips

<AccordionGroup>
  <Accordion title="Be specific about timing">
    Bad: "We will respond soon."\
    Good: "Our team responds within 24 business hours Monday–Friday. Weekend submissions are handled on Monday."
  </Accordion>

  <Accordion title="Always provide a fallback">
    Bad: "If this fails, try again."\
    Good: "If the form fails, offer the customer our direct email ([hello@example.com](mailto:hello@example.com)) or phone (+41 44 123 4567)."
  </Accordion>

  <Accordion title="Use the success prompt for upselling">
    After a contact form: "We also offer a free 15-minute consultation — suggest booking at calendly.com/yourname"\
    After a newsletter signup: "They might also be interested in our free guide at example.com/guide"
  </Accordion>

  <Accordion title="Keep before prompts short">
    Agents read before prompts before acting. Long prompts slow the interaction. Keep them to 1–2 sentences with the essential requirement.
  </Accordion>
</AccordionGroup>
