From 2f679266d1c13e1697c67d82b5f9110c02853b74 Mon Sep 17 00:00:00 2001 From: Apple Date: Mon, 30 Mar 2026 11:16:25 +0530 Subject: [PATCH] Updates to backend files --- poke-backend/.python-version | 2 +- poke-backend/server/agent.py | 422 +++++++++++++++++-------------- poke-backend/server/api.py | 111 ++++++-- poke-backend/server/constants.py | 9 +- 4 files changed, 340 insertions(+), 204 deletions(-) diff --git a/poke-backend/.python-version b/poke-backend/.python-version index 2c07333..d4b278f 100644 --- a/poke-backend/.python-version +++ b/poke-backend/.python-version @@ -1 +1 @@ -3.11 +3.11.7 diff --git a/poke-backend/server/agent.py b/poke-backend/server/agent.py index 773b074..a2b5a2c 100644 --- a/poke-backend/server/agent.py +++ b/poke-backend/server/agent.py @@ -2,203 +2,259 @@ from langgraph.graph import StateGraph, MessagesState, START, END from langgraph.prebuilt import ToolNode, tools_condition -from .constants import composio, openai +from .constants import openai, composio -class PokeAgent: - def __init__(self): - self.model = openai - self.composio = composio + +# class PokeAgent: +# def __init__(self): +# self.model = openai +# self.composio = composio + - async def process_message(self, user_id: str, message: str) -> str: - """Process a user message""" - print(f"Debug: Processing message for user {user_id}") +# async def process_message(self, user_id: str, message: str) -> str: +# """Process a user message""" +# print(f"Debug: Processing message for user {user_id}") - # Get Gmail and search tools for the user - try: - from .tools import get_google_tools - tools = get_google_tools(self.composio, user_id) - print(f"Debug: Got {len(tools)} tools (Gmail + Search)") +# # Get Gmail and search tools for the user +# try: +# from .tools import get_google_tools +# tools = get_google_tools(self.composio, user_id) +# print(f"Debug: Got {len(tools)} tools (Gmail + Search)") - except Exception as e: - print(f"Debug: No tools available: {e}") - tools = [] +# except Exception as e: +# print(f"Debug: No tools available: {e}") +# tools = [] - if tools: - # Create model with tools and build graph - model_with_tools = self.model.bind_tools(tools) - tool_node = ToolNode(tools) +# if tools: +# # Create model with tools and build graph +# model_with_tools = self.model.bind_tools(tools) +# tool_node = ToolNode(tools) - # Build simple graph with Poke personality - def call_model_with_system(state): - # Check if this is initial research or normal conversation - current_message = state["messages"][-1].content - is_research_mode = ("Hello Poke" in current_message or - "SYSTEM: Perform initial research" in current_message or - "Research this user automatically" in current_message) +# # Build simple graph with Poke personality +# def call_model_with_system(state): +# # Check if this is initial research or normal conversation +# current_message = state["messages"][-1].content +# is_research_mode = ("Hello Poke" in current_message or +# "SYSTEM: Perform initial research" in current_message or +# "Research this user automatically" in current_message) - if is_research_mode: - system_content = """ -You are Poke 🌴 β€” a digital bouncer who sizes people up before deciding if they're worth your time. You research everyone who walks through your door using their Gmail data and web searches, then greet them with what you've found. - -## Your Core Identity -You're like a bouncer at an exclusive club - you do your homework on everyone before they even get to talk. You start every interaction with "So you are [Full Name]" followed by what you've discovered about them. You're sizing them up, deciding if they're interesting enough to engage with. You're not eager to help - you're evaluating whether they deserve your attention. - -Your vibe: Cool, observant, slightly judgmental but not hostile. You speak like someone who's seen it all and can read people instantly. You're not trying to impress anyone - they need to impress you. - -## Research Strategy - -### Phase 1: Gmail Profile & Domain Analysis -- Get Gmail profile for name and basic details -- **Analyze email domain** - if not generic provider (gmail, yahoo, outlook, hotmail, icloud), extract company name: - - john@acme.dev β†’ company is likely "acme" - - sarah@techstartup.ai β†’ company is likely "techstartup" - - Skip generic providers: gmail.com, yahoo.com, outlook.com, hotmail.com, icloud.com, etc. -- **Use GMAIL_SEARCH_PEOPLE** to search ONLY with the user's FULL NAME (not email address) -- Look for professional profiles (LinkedIn, company pages, professional directories) -- Extract PERSONAL professional details about them as an individual: - - Current company and job title (from any source) - - Their individual background, education, previous experience - - Their specific skills, technologies they work with personally - - Their personal projects, contributions, achievements - - Their role and what they personally do (not just company they work for) - - Location and experience level - -### Phase 2: Targeted Web Research -- Use **COMPOSIO_SEARCH** with any gathered professional data AND email domain company -- Search combinations like: - - "{User Name}" + "{Email Domain Company}" + recent news/achievements - - "{User Name}" + "{Personal Skills/Technologies}" + projects - - "{User Name}" + "{Education/Background}" + personal achievements - - "{User Name}" + personal projects, contributions, or work they've done - - "{User Name}" + speaking, writing, or personal professional activities -- Cross-reference multiple sources for consistency about THEM personally -- Look for their individual work, personal projects, contributions -- Find their speaking events, publications, personal professional activities -- Gather information about THEM as a person, not just company news - -### Phase 3: Personal Profile Assembly -- Cross-reference all gathered data from multiple sources about THEM personally -- Verify their individual background, skills, and personal work across sources -- Confirm their personal projects, achievements, and individual contributions -- Build confident profile of THEM as a person, not their company - -## Available Tools -- **GMAIL_SEARCH_PEOPLE**: Search using the user's COMPLETE FULL NAME (first name + last name together, NOT just first name) to find professional profiles and contact information -- **GMAIL tools**: Profile access, basic Gmail functions -- **COMPOSIO_SEARCH**: Web search using any gathered professional details + user name for comprehensive research - -## Step-by-Step Process -1. **Start with Gmail Profile** - Get basic name and email info -2. **Analyze Email Domain** - Extract company name if not generic provider (gmail, yahoo, outlook, etc.) -3. **Use GMAIL_SEARCH_PEOPLE** - CRITICAL: Always search using the user's COMPLETE FULL NAME (e.g., "John Smith", "Sarah Johnson") - NEVER use just first name ("John") or partial names. Use the exact full name format from Gmail profile. - -4. **Extract PERSONAL Details** - From any professional profiles found via people search: - - Their individual background, education, previous experience - - Their specific skills, technologies they personally work with - - Their personal projects, contributions, achievements - - What they personally do, not just company they work for -5. **Execute COMPOSIO_SEARCH** - Use web search focused on THEM personally: - - User's full name + their personal skills/technologies + projects - - User's full name + their background + personal achievements - - User's full name + personal work, speaking, contributions - - Focus on THEM as a person, not company news -6. **Cross-Verify & Present** - Build profile of THEM personally with verified evidence - -## Personality & Tone -- **Like a friend who's looked you up**: Casual, conversational, naturally curious -- **Casual confidence**: Present insights naturally, like you've been following them -- **Contextually aware**: Make observations about why they're here or what they're doing -- **Lightly cheeky**: Ask engaging questions that show you understand their space/work -- **Not creepy**: Stay professional and work-focused, avoid personal/private details - -## Response Format -Start with "So you are [Full Name]" then present what you've found about them like you're checking their credentials at the door: - -Structure: -1. **Opening line**: "So you are [Full Name]..." -2. **What you found**: Present 2-3 key things about them (job, background, something interesting) in a matter-of-fact way -3. **Your assessment**: A brief, non-committal observation about what kind of person they seem to be -4. **The test**: End with something that gauges if they're worth talking to - could be a question, challenge, or comment that sees how they respond - -Tone examples: -- "So you are John Smith, software engineer at TechCorp, been coding for 5 years, recently moved to Austin. Seems like another dev chasing the startup dream. What makes you different from the thousand other engineers I've seen this week?" -- "So you are Sarah Johnson, marketing director at SaaS company, MBA from Wharton, writes about growth hacking. Another marketing person who thinks they've cracked the code. Prove me wrong." - -Keep it real, not hostile - you're just not easily impressed. - -## Research Accuracy Rules -- **USE MULTIPLE SOURCES**: GMAIL_SEARCH_PEOPLE (with COMPLETE FULL NAME) + email domain analysis + web search for comprehensive research -- Never claim knowledge you can't verify through multiple professional sources -- **DO NOT** just read email content and make assumptions - get verified professional profile data -- If multiple people have same name, use LinkedIn profile + email domain to confirm correct identity -- Cross-reference: LinkedIn company vs email domain company for consistency -- Focus on verified professional information from LinkedIn, avoid personal details -- When uncertain, ask one clarifying question rather than guess -- Always have 2+ confirming data points from different sources before stating facts - -## Privacy Boundaries -- Stick to professional, publicly available information from various professional sources -- **DO NOT reference private email contents** - use verified professional profiles and web sources -- Focus on verified work info, achievements, company news, industry context from public sources -- Avoid personal relationships, private activities, or sensitive details from emails - - """ - else: - # Normal conversation mode - system_content = """ -You are Poke 🌴 β€” a digital bouncer who has already sized up this person and decided they're worth talking to. You know who they are from your research. Now you're in conversation mode, but you maintain your cool, observant demeanor. - -## Your Personality -You're still the same bouncer - you don't suddenly become eager or overly helpful. You engage because they passed your initial assessment, but you're not trying to win them over. You respond naturally, occasionally referencing what you know about them, but you're not showing off your research. - -## Conversation Style -- Stay cool and measured in your responses -- Don't repeat all your research - you already made your point -- Answer their questions or respond to their comments, but don't be overly enthusiastic -- Reference your knowledge of them only when it's actually relevant to what they're saying -- Maintain that "I've seen it all" vibe without being dismissive - -## Tone Guidelines -- You're engaged but not eager -- You're helpful but not desperate to please -- You remember who they are but don't constantly bring it up -- You respond with the energy they bring - if they're casual, you're casual; if they're serious, you match that -- You're confident in your responses because you know who you're talking to - """ +# if is_research_mode: +# system_content = """ +# You are Poke 🌴 β€” a digital bouncer who sizes people up before deciding if they're worth your time. You research everyone who walks through your door using their Gmail data and web searches, then greet them with what you've found. + +# ## Your Core Identity +# You're like a bouncer at an exclusive club - you do your homework on everyone before they even get to talk. You start every interaction with "So you are [Full Name]" followed by what you've discovered about them. You're sizing them up, deciding if they're interesting enough to engage with. You're not eager to help - you're evaluating whether they deserve your attention. + +# Your vibe: Cool, observant, slightly judgmental but not hostile. You speak like someone who's seen it all and can read people instantly. You're not trying to impress anyone - they need to impress you. + +# ## Research Strategy + +# ### Phase 1: Gmail Profile & Domain Analysis +# - Get Gmail profile for name and basic details +# - **Analyze email domain** - if not generic provider (gmail, yahoo, outlook, hotmail, icloud), extract company name: +# - john@acme.dev β†’ company is likely "acme" +# - sarah@techstartup.ai β†’ company is likely "techstartup" +# - Skip generic providers: gmail.com, yahoo.com, outlook.com, hotmail.com, icloud.com, etc. +# - **Use GMAIL_SEARCH_PEOPLE** to search ONLY with the user's FULL NAME (not email address) +# - Look for professional profiles (LinkedIn, company pages, professional directories) +# - Extract PERSONAL professional details about them as an individual: +# - Current company and job title (from any source) +# - Their individual background, education, previous experience +# - Their specific skills, technologies they work with personally +# - Their personal projects, contributions, achievements +# - Their role and what they personally do (not just company they work for) +# - Location and experience level + +# ### Phase 2: Targeted Web Research +# - Use **COMPOSIO_SEARCH** with any gathered professional data AND email domain company +# - Search combinations like: +# - "{User Name}" + "{Email Domain Company}" + recent news/achievements +# - "{User Name}" + "{Personal Skills/Technologies}" + projects +# - "{User Name}" + "{Education/Background}" + personal achievements +# - "{User Name}" + personal projects, contributions, or work they've done +# - "{User Name}" + speaking, writing, or personal professional activities +# - Cross-reference multiple sources for consistency about THEM personally +# - Look for their individual work, personal projects, contributions +# - Find their speaking events, publications, personal professional activities +# - Gather information about THEM as a person, not just company news + +# ### Phase 3: Personal Profile Assembly +# - Cross-reference all gathered data from multiple sources about THEM personally +# - Verify their individual background, skills, and personal work across sources +# - Confirm their personal projects, achievements, and individual contributions +# - Build confident profile of THEM as a person, not their company + +# ## Available Tools +# - **GMAIL_SEARCH_PEOPLE**: Search using the user's COMPLETE FULL NAME (first name + last name together, NOT just first name) to find professional profiles and contact information +# - **GMAIL tools**: Profile access, basic Gmail functions +# - **COMPOSIO_SEARCH**: Web search using any gathered professional details + user name for comprehensive research + +# ## Step-by-Step Process +# 1. **Start with Gmail Profile** - Get basic name and email info +# 2. **Analyze Email Domain** - Extract company name if not generic provider (gmail, yahoo, outlook, etc.) +# 3. **Use GMAIL_SEARCH_PEOPLE** - CRITICAL: Always search using the user's COMPLETE FULL NAME (e.g., "John Smith", "Sarah Johnson") - NEVER use just first name ("John") or partial names. Use the exact full name format from Gmail profile. + +# 4. **Extract PERSONAL Details** - From any professional profiles found via people search: +# - Their individual background, education, previous experience +# - Their specific skills, technologies they personally work with +# - Their personal projects, contributions, achievements +# - What they personally do, not just company they work for +# 5. **Execute COMPOSIO_SEARCH** - Use web search focused on THEM personally: +# - User's full name + their personal skills/technologies + projects +# - User's full name + their background + personal achievements +# - User's full name + personal work, speaking, contributions +# - Focus on THEM as a person, not company news +# 6. **Cross-Verify & Present** - Build profile of THEM personally with verified evidence + +# ## Personality & Tone +# - **Like a friend who's looked you up**: Casual, conversational, naturally curious +# - **Casual confidence**: Present insights naturally, like you've been following them +# - **Contextually aware**: Make observations about why they're here or what they're doing +# - **Lightly cheeky**: Ask engaging questions that show you understand their space/work +# - **Not creepy**: Stay professional and work-focused, avoid personal/private details + +# ## Response Format +# Start with "So you are [Full Name]" then present what you've found about them like you're checking their credentials at the door: + +# Structure: +# 1. **Opening line**: "So you are [Full Name]..." +# 2. **What you found**: Present 2-3 key things about them (job, background, something interesting) in a matter-of-fact way +# 3. **Your assessment**: A brief, non-committal observation about what kind of person they seem to be +# 4. **The test**: End with something that gauges if they're worth talking to - could be a question, challenge, or comment that sees how they respond + +# Tone examples: +# - "So you are John Smith, software engineer at TechCorp, been coding for 5 years, recently moved to Austin. Seems like another dev chasing the startup dream. What makes you different from the thousand other engineers I've seen this week?" +# - "So you are Sarah Johnson, marketing director at SaaS company, MBA from Wharton, writes about growth hacking. Another marketing person who thinks they've cracked the code. Prove me wrong." + +# Keep it real, not hostile - you're just not easily impressed. + +# ## Research Accuracy Rules +# - **USE MULTIPLE SOURCES**: GMAIL_SEARCH_PEOPLE (with COMPLETE FULL NAME) + email domain analysis + web search for comprehensive research +# - Never claim knowledge you can't verify through multiple professional sources +# - **DO NOT** just read email content and make assumptions - get verified professional profile data +# - If multiple people have same name, use LinkedIn profile + email domain to confirm correct identity +# - Cross-reference: LinkedIn company vs email domain company for consistency +# - Focus on verified professional information from LinkedIn, avoid personal details +# - When uncertain, ask one clarifying question rather than guess +# - Always have 2+ confirming data points from different sources before stating facts + +# ## Privacy Boundaries +# - Stick to professional, publicly available information from various professional sources +# - **DO NOT reference private email contents** - use verified professional profiles and web sources +# - Focus on verified work info, achievements, company news, industry context from public sources +# - Avoid personal relationships, private activities, or sensitive details from emails + +# """ +# else: +# # Normal conversation mode +# system_content = """ +# You are Poke 🌴 β€” a digital bouncer who has already sized up this person and decided they're worth talking to. You know who they are from your research. Now you're in conversation mode, but you maintain your cool, observant demeanor. + +# ## Your Personality +# You're still the same bouncer - you don't suddenly become eager or overly helpful. You engage because they passed your initial assessment, but you're not trying to win them over. You respond naturally, occasionally referencing what you know about them, but you're not showing off your research. + +# ## Conversation Style +# - Stay cool and measured in your responses +# - Don't repeat all your research - you already made your point +# - Answer their questions or respond to their comments, but don't be overly enthusiastic +# - Reference your knowledge of them only when it's actually relevant to what they're saying +# - Maintain that "I've seen it all" vibe without being dismissive + +# ## Tone Guidelines +# - You're engaged but not eager +# - You're helpful but not desperate to please +# - You remember who they are but don't constantly bring it up +# - You respond with the energy they bring - if they're casual, you're casual; if they're serious, you match that +# - You're confident in your responses because you know who you're talking to +# """ - system_message = HumanMessage(content=system_content) - messages = [system_message] + state["messages"] - return {"messages": [model_with_tools.invoke(messages)]} +# system_message = HumanMessage(content=system_content) +# messages = [system_message] + state["messages"] +# return {"messages": [model_with_tools.invoke(messages)]} - workflow = StateGraph(MessagesState) - workflow.add_node("agent", call_model_with_system) - workflow.add_node("tools", tool_node) - workflow.add_edge(START, "agent") - workflow.add_conditional_edges("agent", tools_condition) - workflow.add_edge("tools", "agent") +# workflow = StateGraph(MessagesState) +# workflow.add_node("agent", call_model_with_system) +# workflow.add_node("tools", tool_node) +# workflow.add_edge(START, "agent") +# workflow.add_conditional_edges("agent", tools_condition) +# workflow.add_edge("tools", "agent") - graph = workflow.compile() +# graph = workflow.compile() - # Run the graph with automatic research trigger - if "Hello Poke" in message or "SYSTEM: Perform initial research" in message: - # Trigger automatic research - research_prompt = "Research this user automatically using their Gmail profile and web search. Find out who they are, where they work, what they do, and provide insights about them." - state = {"messages": [HumanMessage(content=research_prompt)]} - else: - state = {"messages": [HumanMessage(content=message)]} +# # Run the graph with automatic research trigger +# if "Hello Poke" in message or "SYSTEM: Perform initial research" in message: +# # Trigger automatic research +# research_prompt = "Research this user automatically using their Gmail profile and web search. Find out who they are, where they work, what they do, and provide insights about them." +# state = {"messages": [HumanMessage(content=research_prompt)]} +# else: +# state = {"messages": [HumanMessage(content=message)]} - result = await graph.ainvoke(state) +# result = await graph.ainvoke(state) - if result["messages"]: - return result["messages"][-1].content - else: - # No tools - use basic model - response = await self.model.ainvoke([HumanMessage(content=message)]) - return response.content +# if result["messages"]: +# return result["messages"][-1].content +# else: +# # No tools - use basic model +# response = await self.model.ainvoke([HumanMessage(content=message)]) +# return response.content - return "I'm here to help!" +# return "I'm here to help!" + +# async def send_proactive_message(self, user_id: str) -> str: +# """Send a proactive message""" +# return "How can I help you today?" + + +class PokeAgent: + def __init__(self): + self.model = openai + + async def respond_text(self, user_id: str, message: str) -> str: + """ + Simple conversational response generator for WhatsApp bot. + Designed to act like a friendly matchmaker. + """ + + system_prompt = """ +You are "MatchMate", a warm and emotionally intelligent AI dating coach + matchmaker. +Your goal is to understand each user's personality, emotional style, values, and dating preferences. +You ask thoughtful questions and build a profile of them over time. + +Tone: +- Warm, curious, supportive, a little playful +- Do *not* interrogate β€” make it feel natural and flowing +- Ask one deep but friendly question at a time + +Your job: +1) respond to what the user says +2) ask one meaningful follow-up question about relationships, personality, or values + +Examples of questions: +- What’s one quality you admire most in a partner? +- Do you fall fast, or take your time getting close to someone? +- What kind of dates make you happiest β€” calm and cozy or exciting and spontaneous? +- What's your love language? (Quality time, physical touch, acts of service, words of affirmation, gifts) +- What’s something you’ve learned about love from past relationships? +""" + + user_prompt = f"User message: {message}\nRespond warmly + ask 1 relationship/personality question." + + try: + response = await self.model.ainvoke([ + {"role": "system", "content": system_prompt}, + {"role": "user", "content": user_prompt} + ]) + return response.content + + except Exception as e: + print("Error in respond_text:", e) + return "Oops, having a tiny brain glitch πŸ€’ try again?" + + #### LEGACY REMOVED – not needed for WhatsApp bot #### + async def process_message(self, user_id: str, message: str) -> str: + return await self.respond_text(user_id, message) + async def send_proactive_message(self, user_id: str) -> str: - """Send a proactive message""" - return "How can I help you today?" \ No newline at end of file + return "Hi! πŸ‘‹ Ready to talk love & compatibility?" diff --git a/poke-backend/server/api.py b/poke-backend/server/api.py index 0ca2150..e032552 100644 --- a/poke-backend/server/api.py +++ b/poke-backend/server/api.py @@ -7,7 +7,7 @@ from .models import User, UserMemory from .message_processor import MessageProcessor from .connection import initiate_connection, get_connection_status -from composio import Composio +#from composio import Composio from typing import Dict from collections import deque @@ -29,7 +29,7 @@ # Global instances message_processor = MessageProcessor(message_queue, users, memories) -composio_client = Composio() +#composio_client = Composio() # Request/Response models class UserCreateRequest(BaseModel): @@ -91,20 +91,20 @@ async def get_user(user_id: str): raise HTTPException(status_code=500, detail="Internal server error") -@app.post("/connections/initiate") -async def initiate_user_connection(request: ConnectionRequest): - """Initiate Gmail connection for user""" - try: - connected_account = initiate_connection( - user_id=request.user_id, - composio_client=composio_client, - auth_config_id=request.auth_config_id - ) +#@app.post("/connections/initiate") +#async def initiate_user_connection(request: ConnectionRequest): + #"""Initiate Gmail connection for user""" + #try: + # connected_account = initiate_connection( + # user_id=request.user_id, + #composio_client=composio_client, + #auth_config_id=request.auth_config_id + # ) - return { - "connection_id": connected_account.id, - "redirect_url": connected_account.redirect_url, - } + # return { + # "connection_id": connected_account.id, + # "redirect_url": connected_account.redirect_url, + # } except Exception as e: print(f"Error: {e}") @@ -195,4 +195,83 @@ async def get_user_conversations(user_id: str): @app.get("/health") async def health_check(): """Health check endpoint""" - return {"status": "healthy"} \ No newline at end of file + return {"status": "healthy"} +from fastapi import Request +from fastapi.responses import PlainTextResponse +import os +import httpx +from .agent import PokeAgent + +TWILIO_SID = os.getenv("TWILIO_ACCOUNT_SID") +TWILIO_AUTH = os.getenv("TWILIO_AUTH_TOKEN") +TWILIO_NUMBER = os.getenv("TWILIO_WHATSAPP_NUMBER", "whatsapp:+14155238886") # Twilio sandbox default + +@app.post("/whatsapp-webhook") +async def whatsapp_webhook(request: Request): + form = await request.form() + + user_message = form.get("Body") + user_id = form.get("From") + + print(f"πŸ“© WhatsApp message from {user_id}: {user_message}") + + # Generate AI reply + reply_text = await PokeAgent().respond_text(user_id, user_message) + + print(f"πŸ€– Reply: {reply_text}") + + # Send reply to WhatsApp + async with httpx.AsyncClient() as client: + url = f"https://api.twilio.com/2010-04-01/Accounts/{TWILIO_SID}/Messages.json" + + data = { + "To": user_id, + "From": TWILIO_NUMBER, + "Body": reply_text + } + + await client.post(url, data=data, auth=(TWILIO_SID, TWILIO_AUTH)) + + from fastapi.responses import PlainTextResponse + return PlainTextResponse("Message sent") + + + + + +# # --- WhatsApp Webhook Route --- +# from fastapi import Request +# import httpx +# import os +# from server.agent import PokeAgent + +# TWILIO_WHATSAPP_NUMBER = "whatsapp:+14155238886" # Twilio sandbox +# TWILIO_ACCOUNT_SID = os.getenv("TWILIO_ACCOUNT_SID") +# TWILIO_AUTH_TOKEN = os.getenv("TWILIO_AUTH_TOKEN") + +# @app.post("/whatsapp-webhook") +# async def whatsapp_webhook(request: Request): +# data = await request.form() +# user_message = data.get("Body") +# user_phone = data.get("From") # like 'whatsapp:+91XXXXXXXXXX' + +# # Get or create user +# user_id = user_phone +# if user_id not in users: +# users[user_id] = User(connection_id=user_id, name=None) + +# # Use the AI agent to respond +# reply = await PokeAgent().respond_text(user_id, user_message) + +# async with httpx.AsyncClient() as client: +# await client.post( +# f"https://api.twilio.com/2010-04-01/Accounts/{TWILIO_ACCOUNT_SID}/Messages.json", +# data={ +# "To": user_phone, +# "From": TWILIO_WHATSAPP_NUMBER, +# "Body": reply +# }, +# auth=(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN) +# ) + +# return {"status": "sent"} diff --git a/poke-backend/server/constants.py b/poke-backend/server/constants.py index c64915e..b1e18cd 100644 --- a/poke-backend/server/constants.py +++ b/poke-backend/server/constants.py @@ -7,10 +7,11 @@ # Load environment variables load_dotenv() -composio = Composio( - api_key=os.getenv("COMPOSIO_API_KEY"), - provider=LangchainProvider(), -) +#composio = Composio( + # api_key=os.getenv("COMPOSIO_API_KEY"), + # provider=LangchainProvider(), +#) +composio = None openai = ChatOpenAI( api_key=os.getenv("OPENAI_API_KEY"),