import os
import requests
payload = {
"input_prompt": "🌱 What are the best rice varieties for the Kharif season?",
"messages": [
{"role": "user", "content": "what is best weather to grow rice?"},
{
"role": "assistant",
"content": 'Welcome to Farmer.CHAT. I\'m an AI 🤖 designed to help farmers and extension agents. Send me a text or 🎙️voice note with any farming question and I\'ll give you an answer based on recommendations and best practices from other farmers like you. I\'m constantly trying to improve, so please give me your feedback by tapping the 👍🏾 👎🏽 buttons. \n\nPlease respond with "✅ I Agree" to let us know you understand that your messages will be retained to start using this service. \n<button gui-action="disable_feedback" gui-target="input_prompt">✅ I Agree</button>',
},
{"role": "user", "content": "✅ I Agree"},
{
"role": "assistant",
"content": 'Thank you for agreeing! 😊\n\nNow, let me answer your question about the **best weather to grow rice** 🌾:\n\nThe search results don\'t directly cover rice, but here\'s what I know based on best farming practices:\n\n### 🌡️ Best Weather Conditions for Rice:\n\n1. **Temperature**: Rice grows best in **warm weather** between **20°C to 37°C**. The ideal temperature is around **25°C to 30°C**.\n\n2. **Rainfall**: Rice needs **plenty of water** 💧. It thrives in areas with **150–200 cm of annual rainfall**. That\'s why it\'s mainly grown during the **monsoon season (Kharif)** in India (June–July sowing).\n\n3. **Humidity**: Rice loves **high humidity** (above 60%). This helps in proper growth and grain filling.\n\n4. **Sunlight**: Rice needs **good sunlight** ☀️ for at least 4–6 hours a day, especially during the grain-filling stage.\n\n5. **Season**: In India, rice is mainly grown in two seasons:\n - **Kharif (June–November)** – most common\n - **Rabi/Summer (January–May)** – in irrigated areas\n\n### ⚠️ Conditions to Avoid:\n- Temperatures **below 15°C** can damage the crop\n- **Frost** is very harmful to rice\n- **Drought or dry spells** during flowering reduce yield\n\n---\n\nTo help you better, could you share your **location**, **gender**, and **other crops you grow**? This will help me give more tailored advice! 🙏\n\n---\n\nHere are some follow-up questions you might find helpful:\n\n🌱 What are the best rice varieties for the Kharif season?\n💧 How much water does rice need during different growth stages?\n🐛 What are common pests in rice and how to control them?\n\n<button gui-target="input_prompt">🌱 What are the best rice varieties for the Kharif season?</button>\n<button gui-target="input_prompt">💧 How much water does rice need during different growth stages?</button>\n<button gui-target="input_prompt">🐛 What are common pests in rice and how to control them?</button>',
},
],
}
response = requests.post(
"https://api.gooey.ai/v2/agent?example_id=nuwsqmzp",
headers={
"Authorization": "bearer " + os.environ["GOOEY_API_KEY"],
},
json=payload,
)
assert response.ok, response.content
result = response.json()
print(response.status_code, result)