I’m working on a Python app that uses AI to chat with job candidates and analyze their behavior. My current setup works but I want to make it better by adding LangGraph for smarter conversation handling.
Here’s what my code looks like right now:
import os
import json
import openai
from personality_data import PERSONALITY_TYPES
# Save chat history to JSON file
def store_chat_history(chat_data):
filename = f"interview_{os.urandom(4).hex()}.json"
with open(filename, 'w') as output_file:
json.dump(chat_data, output_file, indent=2)
return filename
# Get candidate information
def collect_candidate_info():
ai_model = openai.ChatCompletion()
greeting_prompt = "Create a welcoming message to ask for the candidate's full name. Keep it professional but warm."
ai_response = ai_model.create(messages=[{"role": "user", "content": greeting_prompt}])
greeting_text = ai_response.choices[0].message.content
user_name = input(f"AI Interviewer: {greeting_text}\nYour answer: ").strip()
print(f"AI Interviewer: Nice to meet you, {user_name}. We'll start the behavioral assessment now.")
return user_name
# Get response from candidate
def collect_response(question_text):
while True:
answer = input(f"AI Interviewer: {question_text}\nYour response: ").strip()
if answer:
return answer
print("AI Interviewer: I didn't catch that. Could you please answer the question?")
# Start the interview process
candidate_info = collect_candidate_info()
I’ve been trying to use CrewAI and looked into LangGraph but I’m pretty new to this stuff and getting confused about how to set it up properly. My current system can do basic chat and save conversations but I want to make the flow more dynamic.
I’ve managed to:
Build basic chat features with CrewAI for talking to candidates
Started looking at LangGraph to make better conversation trees
Created helper functions for introductions and getting responses with OpenAI
What I need help with:
How do I actually add LangGraph to what I already have without breaking everything?
Are there easier alternatives that might work better for a beginner?
What’s the best way to structure AI agents for interview scenarios?
I’m hoping someone here has experience with this kind of integration and can point me in the right direction. Thanks for any help!
Been down this exact path with a talent acquisition tool last year. Don’t replace your current setup - layer LangGraph on top of what works. Your OpenAI integration stays intact, just gets orchestrated differently.
What worked for me: treat each interview stage as a separate graph node. Your collect_candidate_info() becomes one node, behavioral questions another, technical assessment a third. The magic happens in the edges between nodes where you define routing logic based on responses.
One thing I learned the hard way - don’t make LangGraph handle the actual OpenAI calls. Keep those in your existing functions and let LangGraph manage conversation state and decision flow. Your store_chat_history() function becomes even more valuable because you can capture the entire graph execution path.
Skip CrewAI for this. It’s designed for multi-agent collaboration, not conversation management. LangGraph gives you exactly what you need - stateful conversation flows with conditional routing. The learning curve’s gentler too since you can migrate one conversation branch at a time while keeping everything else running.
I built something similar for recruiting and hit the same confusion trying to add LangGraph to existing chat logic.
Here’s what clicked for me: don’t rebuild everything. Wrap your current OpenAI calls inside LangGraph nodes and add state management piece by piece.
Start simple - three nodes: greeting, question asking, response collection. Each node calls your existing functions like collect_candidate_info() and collect_response(). LangGraph handles conversation state and flow between nodes automatically.
The conditional routing is gold for interviews. Set up logic where the AI picks the next question based on previous answers. Beats hardcoded sequences every time.
Go with LangGraph over CrewAI here. CrewAI’s overkill when you just need conversation flow. LangGraph gives you state management without the agent coordination bloat.
Quick tip - keep your store_chat_history() function but tweak it to save the LangGraph state object. You can resume conversations or analyze the full decision tree later.
You don’t need to migrate everything to LangGraph at once. I hit similar issues upgrading our interview platform - going gradual works way better. Your current code structure actually fits LangGraph nodes perfectly. Just think of each conversation phase as its own node: greeting, questioning, analysis, wrap-up. Your existing functions become the node implementations, and LangGraph handles state transitions. The real win is dynamic question sequencing. No more fixed scripts - you can build conditional edges that adapt to candidate responses. Weak leadership answer? The graph automatically routes to follow-up leadership scenarios. For CrewAI vs LangGraph - go with LangGraph here. CrewAI’s great for multi-agent stuff but overkill for conversation flows. Plus LangGraph’s state persistence plays nice with your store_chat_history function. Start small: convert your greeting flow into a two-node graph. Once that’s working, add more complexity. Much easier learning curve than starting over.