Documentation
Agents
Overview
Agents enable the creation of fully autonomous flows, delivering on-demand customer care seamlessly. They utilize the instructions, knowledge, alignment, and actions you provide them with to effectively respond to interactions from any connected source and perform any actions you’d like them to take.
Source
To start an agent, you first need to receive an interaction from a source. You can select this source when you create an agent or change it later using the "Settings" button in the top bar. You have the option to set a default source or choose one from platforms like Shopify or Stripe. Here’s a list of our default sources:
- Email: A unique email address to forward emails directly to your agent. It understands the entire email content, including attachments like PDFs and images.
- Phone: A dedicated unique phone number that allows customers to call in, enabling the agent to take action on the full conversation in real-time.
- Webhook: A unique webhook url that can be called programmatically, with the body of the request serving as the interaction for the agent. Read the webhook section in the docs to learn more.
- Integrations: We’re continuously expanding our integrations. Integrations empower your agents to take action whenever an event occurs in the tools and services you already use. For instance, agents can respond to events like incoming orders from Shopify or Stripe, or new customer entries in HubSpot.
Webhook
The webhook source enables you to programmatically initiate an agent by providing an interaction. To set this up, simply select "Webhook" as the source for the agent. This generates a unique URL for you to call. For instance, you can make an API call from your checkout flow, sign-up form, or other sections of your product or service.
The body of the API call can be fully dynamic, accommodating a wide range of file types, including JPG, JPEG, PNG, MP4, MP2, MP3, M4A, JSON, MBOX, HWP, PPTX, DOCX, PPTM, PPT, EPUB, MD, CSV, TXT, and PDF.
You have to include a contact with your webhook call, allowing you to group all chat history and context data. This will also organize the conversation into a new thread in your inbox. All chat history and context associated with this unique contact will be stored in a dataset. Contacts are built using a name, email, phone, company, and address.
For each webhook call a contact email or phone number has to be provided. The other fields are optional.
Here’s an example API call:
// Textual input-only
curl --location 'INSERT WEBHOOK URL HERE' \
--form 'message="Some user input"' \
--form 'contact.name="Jane Doe"' \
--form 'contact.email="jane@gmail.com"' \
--form 'contact.phone="123456789"' \
--form 'contact.company="Lemni"' \
--form 'contact.address="123 Main St, Anytown, USA"'
// Input with files
curl --location 'INSERT WEBHOOK URL HERE' \
--form 'message="Some user input"' \
--form 'contact.name="Jane Doe"' \
--form 'contact.email="jane@gmail.com"' \
--form 'contact.phone="123456789"' \
--form 'contact.company="Lemni"' \
--form 'contact.address="123 Main St, Anytown, USA"' \
--form 'files[]="Some files"'
Prompt
Add a prompt for your agent to let it respond to an interaction. A prompt is built using a couple building blocks; Instructions, an Ai model (LLM), knowledge, actions, and alignment rulesets. By combining these fundamentals you’ll give your agent to power to take action and resolve complex problems and automations.
Instructions
Fundamental to each agent are their instructions. Instruct the Ai agent so that it understands what it needs to do. Lemni automatically recommends the relevant actions to use from the action store, based on the instructions you write.
To write a good instruction you summon the agent to do things based on the interaction provided from the source. The more detailed you write the instructions, the better the agent becomes at consistently performing them. Below you’ll find some relevant examples.
EXAMPLE INSTRUCTION A
Write an email to answer the question, then send it using gmail.
EXAMPLE INSTRUCTION B
When the email has car damage images:
- Generate a Damage Report:
- Analyze the attached car damage image.
- Draft a detailed damage report that includes:
- Car brand and model.
- Damage assessment.
- Estimated repair cost.
- Send Slack Notification for High-Cost Repairs:
- If the estimated repair cost exceeds $5000:
- Send a concise summary of the damage report via Slack, including:
- Key findings from the report.
- Total cost estimate.
- Assign one of the following agents to review the report: Dave, Joe, or Jane.
- Send a concise summary of the damage report via Slack, including:
- If the estimated repair cost exceeds $5000:
- Process Payment for Lower-Cost Repairs:
- If the estimated repair cost is $5000 or below:
- Initiate a payment for the estimated repair amount using Stripe.
- If the estimated repair cost is $5000 or below:
- Email Response to Customer:
- Compose an email response to the customer summarizing:
- Estimated repair cost.
- Actions being taken to resolve their claim.
- Send the email through Gmail.
- Compose an email response to the customer summarizing:
EXAMPLE INSTRUCTION C
When a technical issue or bug is reported, create a GitHub issue with the following structure:
- Title: Brief summary of the issue.
- Description: Detailed description, including steps to reproduce, observed behavior, and expected outcome.
- Error Messages/Logs: Include any specific messages or logs if available.
- Customer Reference: Mention the customer experiencing the issue by name or ID.
- Additional Tags: Include priority, urgency, or affected module tags if relevant.
Model (LLM)
Lemni lets you select the best large language model for the task at hand. Each model offers unique performance characteristics and strengths, allowing you to select the one that best suits your needs. When creating an agent, simply use the model selector located at the bottom left to switch between popular models, including OpenAI's GPT-4, Anthropic's Sonnet, Google Gemini, and Llama. Once you've made your selection, the chosen model will seamlessly handle the execution of your instructions.
Knowledge
Leverage knowledge to train agents on your business using a variety of data, including files, webpages, and more. You can efficiently organize this information in the "Knowledge" section of the app using datasets.
For each agent, you can choose the specific datasets you want to utilize. For instance, consider incorporating documents related to your return policies. Alternatively, combine documents about your company, technology, and webpages with FAQs to enhance your responses to customer support emails.
By default, we select all available knowledge when an agent is created; however, you can deselect any irrelevant datasets to improve the agent performance and consistency.
Behavior
Set behavior rules to ensure your agent follows the correct brand language and safety guidelines. Use the menu in the agent editor to select or deselect options to control how the agent adheres to them. Easily create and manage the rulesets in the behavior section.
Actions
When crafting an agent, it’s essential to empower it to perform the desired action. By utilizing actions, you can seamlessly integrate your agents with various apps and services, enabling them to perform the job.
To streamline your setup process, we automatically recommend relevant actions based on your instructions. Simply click on an action to enable it for the agent.
Alternatively, you can click "Browse" to search both the action store and your private action library. You can use the private action library to code your own actions to connect agents with your systems. Learn more about building and managing actions in the actions section of the docs.