How to create a reliable conversational AI proxy using Parlant?
Parlant is a framework designed to help developers build production AI agents that act continuously and reliably. A common challenge when deploying large language model (LLM) agents is that they usually perform well in testing but fail when interacting with real users. They may ignore well-designed system prompts, produce inaccurate or irrelevant reactions at critical moments, struggle with marginal cases, or inconsistent behavior from one conversation to another.
Parlant addresses these challenges by shifting focus from rapid engineering to principle-driven development. Instead of relying on prompts alone, it provides a mechanism for well-defined rules and tool integration to ensure that agents can access and process real-world data safely and predictably.
In this tutorial, we will create an insurance agent that can retrieve open claims, file new claims and provide detailed policy information to demonstrate how to integrate domain-specific tools into powered AI systems for consistent and reliable customer support. Check The complete code is here.
Install and import dependencies
import asyncio
from datetime import datetime
import parlant.sdk as p
Definition Tool
The following code block describes three tools that simulate interactions that insurance assistants may need.
- this get_open_claims The tool represents an asynchronous feature that retrieves an open insurance claim list, allowing agents to provide users with the latest information about pending or approved claims.
- this file_claim The tool accepts claim details as input and simulates the process of filing a new insurance claim and returns a confirmation message to the user.
at last, get_policy_details The tool provides basic policy information, such as policy numbers and coverage, allowing agents to answer questions about insurance coverage accurately. Check The complete code is here.
@p.tool
async def get_open_claims(context: p.ToolContext) -> p.ToolResult:
return p.ToolResult(data=["Claim #123 - Pending", "Claim #456 - Approved"])
@p.tool
async def file_claim(context: p.ToolContext, claim_details: str) -> p.ToolResult:
return p.ToolResult(data=f"New claim filed: {claim_details}")
@p.tool
async def get_policy_details(context: p.ToolContext) -> p.ToolResult:
return p.ToolResult(data={
"policy_number": "POL-7788",
"coverage": "Covers accidental damage and theft up to $50,000"
})
Define glossary and journey
In this section, we define the journey of glossary and shaping how agents handle domain knowledge and dialogue. The glossary contains important business terms such as customer service numbers and operating hours, allowing agents to accurately refer to them when needed.
These journeys describe the step-by-step process of a specific task. In this example, one journey guides the client by making a new insurance claim, while the other focuses on retrieving and interpreting the details of the policy’s scope. Check The complete code is here.
async def add_domain_glossary(agent: p.Agent):
await agent.create_term(
name="Customer Service Number",
description="You can reach us at +1-555-INSURE",
)
await agent.create_term(
name="Operating Hours",
description="We are available Mon-Fri, 9AM-6PM",
)
async def create_claim_journey(agent: p.Agent) -> p.Journey:
journey = await agent.create_journey(
title="File an Insurance Claim",
description="Helps customers report and submit a new claim.",
conditions=["The customer wants to file a claim"],
)
s0 = await journey.initial_state.transition_to(chat_state="Ask for accident details")
s1 = await s0.target.transition_to(tool_state=file_claim, condition="Customer provides details")
s2 = await s1.target.transition_to(chat_state="Confirm claim was submitted")
await s2.target.transition_to(state=p.END_JOURNEY)
return journey
async def create_policy_journey(agent: p.Agent) -> p.Journey:
journey = await agent.create_journey(
title="Explain Policy Coverage",
description="Retrieves and explains customer's insurance coverage.",
conditions=["The customer asks about their policy"],
)
s0 = await journey.initial_state.transition_to(tool_state=get_policy_details)
await s0.target.transition_to(
chat_state="Explain the policy coverage clearly",
condition="Policy info is available",
)
await agent.create_guideline(
condition="Customer presses for legal interpretation of coverage",
action="Politely explain that legal advice cannot be provided",
)
return journey
The main runner ties all components defined in the early cells together and starts the proxy. It launches a Parlant server, creates an insurance support agent, and loads its glossary, journeys and global guides. It also handles edge cases such as vague customer intent by prompting the agent to choose between relevant journeys. Finally, once the script is executed, the server becomes active and prints a confirmation message. You can then open your browser and navigate to Access the Parlant UI and start interacting with insurance agents in real time. Check The complete code is here.
async def main():
async with p.Server() as server:
agent = await server.create_agent(
name="Insurance Support Agent",
description="Friendly and professional; helps with claims and policy queries.",
)
await add_domain_glossary(agent)
claim_journey = await create_claim_journey(agent)
policy_journey = await create_policy_journey(agent)
# Disambiguation: if intent is unclear
status_obs = await agent.create_observation(
"Customer mentions an issue but doesn't specify if it's a claim or policy"
)
await status_obs.disambiguate([claim_journey, policy_journey])
# Global guideline
await agent.create_guideline(
condition="Customer asks about unrelated topics",
action="Kindly redirect them to insurance-related support only",
)
print("✅ Insurance Agent is ready! Open the Parlant UI to chat.")
if __name__ == "__main__":
import asyncio
asyncio.run(main())

Check The complete code is here. Check out ours anytime Tutorials, codes and notebooks for github pages. Also, please stay tuned for us twitter And don’t forget to join us 100K+ ml reddit And subscribe Our newsletter.
Talk to us about your content partnership with Marktechpost.com

I am a civil engineering graduate in Islamic Islam in Jamia Milia New Delhi (2022) and I am very interested in data science, especially neural networks and their applications in various fields.
🔥[Recommended Read] NVIDIA AI Open Source VIPE (Video Pose Engine): A powerful and universal 3D video annotation tool for spatial AI