1HOUSE API Documentation

Intelligence (AI Chatbot)

Interact with AI-powered trading and personal development assistant

AI-powered chatbot providing trading strategies, risk management advice, and personal development guidance.

AI-Powered Assistant

Our GPT-4 powered chatbot specializes in trading strategies, risk management, and personal development. Provides focused, actionable advice for traders and professionals.

Overview

The Intelligence Service is an AI assistant that provides:

  • Trading strategy advice
  • Risk management guidance
  • Technical analysis insights
  • Personal development coaching
  • Sales and business advice

Powered by: OpenAI GPT-4

Focus Areas:

  • **Trading and forex strategies
  • **Risk management
  • **Technical indicators
  • **Personal development
  • **Sales and business growth
  • **Off-topic questions (politely redirects)

Endpoints

Initialize Intelligence Page

Get topics, conversation history, and quick prompts.

GET /v1/intelligence/initialize
X-API-Key: your-api-key
Authorization: Bearer your-jwt-token
{
  "success": true,
  "status": 200,
  "message": "Intelligence page initialized",
  "data": {
    "topics": [
      {
        "id": "topic_123",
        "title": "Forex Trading Strategies",
        "description": "Expert insights on forex trading",
        "icon": "💹",
        "prompt": "Tell me about forex trading strategies",
        "category": "trading"
      },
      {
        "id": "topic_456",
        "title": "Risk Management",
        "description": "Position sizing and risk control",
        "icon": "🛡️",
        "prompt": "How do I manage trading risk?",
        "category": "trading"
      }
    ],
    "recentConversations": [
      {
        "id": "conv_789",
        "title": "EUR/USD Analysis",
        "messageCount": 12,
        "lastMessageAt": "2025-10-21T10:30:00.000Z"
      }
    ],
    "quickPrompts": [
      "Analyze current EUR/USD trend",
      "What's the best entry strategy for GBP/JPY?",
      "Explain RSI indicator",
      "How to manage risk on volatile pairs?"
    ]
  },
  "meta": {
    "timestamp": "2025-10-21T12:00:00.000Z",
    "version": "v1"
  }
}

Get Conversation Messages

Retrieve all messages from a specific conversation.

POST /v1/intelligence/conversation/initialize
X-API-Key: your-api-key
Authorization: Bearer your-jwt-token
Content-Type: application/json
{
  "conversation_id": "conv_789"
}
{
  "success": true,
  "status": 200,
  "message": "Conversation retrieved",
  "data": [
    {
      "id": "msg_001",
      "sender": "user_456",
      "message": "How do I analyze EUR/USD trends?",
      "role": "user",
      "created": "2025-10-21T10:00:00.000Z"
    },
    {
      "id": "msg_002",
      "sender": "system",
      "message": "To analyze EUR/USD trends effectively, focus on these key areas:\n\n1. **Technical Analysis:**\n   - Check daily and 4-hour charts for trend direction\n   - Look for support and resistance levels\n   - Use moving averages (50 and 200 EMA)\n\n2. **Market Fundamentals:**\n   - Monitor ECB and Fed policy\n   - Watch economic indicators (GDP, inflation)\n   - Track interest rate differentials\n\n3. **Risk Management:**\n   - Always use stop losses\n   - Risk no more than 1-2% per trade\n   - Calculate position size before entry\n\nWhat specific aspect would you like to explore?",
      "role": "assistant",
      "tokens": {
        "prompt": 45,
        "completion": 152,
        "total": 197
      },
      "model": "gpt-4",
      "created": "2025-10-21T10:00:05.000Z"
    }
  ],
  "meta": {
    "timestamp": "2025-10-21T12:00:00.000Z",
    "version": "v1"
  }
}

Send Prompt to AI

Send a message to the AI assistant.

POST /v1/intelligence/prompt/send
X-API-Key: your-api-key
Authorization: Bearer your-jwt-token
Content-Type: application/json
{
  "conversation_id": "conv_789",
  "prompt": "What about using RSI with this strategy?"
}

For New Conversation:

{
  "conversation_id": null,
  "prompt": "How do I start trading forex?"
}
{
  "success": true,
  "status": 201,
  "message": "Message sent successfully",
  "data": {
    "conversation": "conv_789",
    "messages": [
      {
        "id": "msg_001",
        "sender": "user_456",
        "message": "How do I analyze EUR/USD trends?",
        "role": "user",
        "created": "2025-10-21T10:00:00.000Z"
      },
      {
        "id": "msg_002",
        "sender": "system",
        "message": "To analyze EUR/USD trends...",
        "role": "assistant",
        "created": "2025-10-21T10:00:05.000Z"
      },
      {
        "id": "msg_003",
        "sender": "user_456",
        "message": "What about using RSI with this strategy?",
        "role": "user",
        "created": "2025-10-21T10:01:00.000Z"
      },
      {
        "id": "msg_004",
        "sender": "system",
        "message": "Great question! RSI (Relative Strength Index) is an excellent addition:\n\n**How to Use RSI:**\n- Above 70 = Overbought (potential sell signal)\n- Below 30 = Oversold (potential buy signal)\n- Divergence patterns indicate trend reversals\n\n**With EUR/USD:**\n- Combine RSI with support/resistance\n- Wait for RSI < 30 at support level for strong buy\n- Use 14-period RSI on 4H or Daily charts\n\nWould you like to discuss entry timing?",
        "role": "assistant",
        "tokens": {
          "prompt": 234,
          "completion": 142,
          "total": 376
        },
        "created": "2025-10-21T10:01:03.000Z"
      }
    ]
  },
  "meta": {
    "timestamp": "2025-10-21T12:00:00.000Z",
    "version": "v1"
  }
}

Conversation Flow

1. Initialize Page (First Visit)

// Get topics and history
const init = await fetch('/v1/intelligence/initialize', {
  headers: {
    'X-API-Key': apiKey,
    'Authorization': `Bearer ${token}`
  }
});

const { data } = await init.json();
// Display topics and recent conversations to user

2. Start New Conversation

// User clicks a topic or enters a prompt
const response = await fetch('/v1/intelligence/prompt/send', {
  method: 'POST',
  headers: {
    'X-API-Key': apiKey,
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    conversation_id: null,  // New conversation
    prompt: "How do I start trading forex?"
  })
});

const { data } = await response.json();
// data.conversation = new conversation ID
// data.messages = array of messages (user + AI response)

3. Continue Conversation

// User sends follow-up question
const response = await fetch('/v1/intelligence/prompt/send', {
  method: 'POST',
  headers: {
    'X-API-Key': apiKey,
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    conversation_id: "conv_789",  // Existing conversation
    prompt: "What about EUR/USD specifically?"
  })
});

const { data } = await response.json();
// data.messages = full conversation history including new messages

4. Load Previous Conversation

// User clicks on a past conversation
const response = await fetch('/v1/intelligence/conversation/initialize', {
  method: 'POST',
  headers: {
    'X-API-Key': apiKey,
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    conversation_id: "conv_789"
  })
});

const { data } = await response.json();
// data = array of all messages in conversation

AI Capabilities

Trading Advice

Prompt: "What's the best strategy for EUR/USD in current market?"

AI Response: Provides specific, actionable trading advice based on:
- Technical analysis
- Support/resistance levels
- Risk management
- Entry/exit strategies

Risk Management

Prompt: "How much should I risk per trade?"

AI Response: Explains:
- 1-2% rule
- Position sizing calculations
- Stop loss placement
- Risk/reward ratios

Learning & Education

Prompt: "Explain MACD indicator"

AI Response: Provides:
- Clear explanation
- How to use it
- Trading signals
- Real-world examples

Personal Development

Prompt: "How do I stay disciplined in trading?"

AI Response: Offers:
- Trading psychology tips
- Discipline strategies
- Emotional management
- Success mindset

Configuration

System Prompt

The AI is configured with:

You are a smart assistant that gives ONLY sales and personal development advice.
Be direct, real-world focused, and motivational when needed.
Focus on trading strategies, risk management, mindset, and business development.
Do NOT answer questions outside of these topics.

Model Settings

  • Model: GPT-4
  • Max Tokens: 1000 per response
  • Temperature: 0.7 (balanced creativity)

Token Tracking

Each AI response includes token usage for billing:

{
  "tokens": {
    "prompt": 234,
    "completion": 142,
    "total": 376
  }
}

Pricing Estimate:

  • GPT-4: ~$0.03 per 1K tokens input, ~$0.06 per 1K tokens output
  • Average conversation: 50-100 messages = $1-2

Privacy & Security

  • **Conversations are private to each user
  • **Messages are encrypted at rest
  • **No sharing of personal data with OpenAI beyond prompts
  • **Conversation history stored securely
  • **Users can delete conversations anytime

Limits

LimitValue
Max conversations per user100
Max messages per conversation500
Max prompt length2000 characters
Response time~3-5 seconds

Tips for Best Results

Be Specific

**"Tell me about trading" **"What's the best entry strategy for EUR/USD when RSI is below 30?"

Provide Context

{
  "prompt": "I'm looking at EUR/USD on the 4H chart. Price is at 1.0850, RSI is 28, and there's support at 1.0800. Should I enter?"
}

Follow-up Questions

Build on previous context:

1. "How do I analyze EUR/USD?"
2. "What about using RSI?"
3. "Where should I place my stop loss?"
4. "What's a good position size for 2% risk?"

Troubleshooting

The AI only answers trading/personal development questions. If you get this response, rephrase to focus on:

  • Trading strategies
  • Risk management
  • Market analysis
  • Personal growth
  • Sales/business

Slow Response

Normal response time is 3-5 seconds. If slower:

  • Check your internet connection
  • Verify OpenAI service status
  • Try again in a moment

Token Limit Exceeded

If conversation is very long (500+ messages):

  • Start a new conversation
  • Reference previous topics briefly
  • Summarize key points

UI Integration Example

// React component example
function AIChat() {
  const [messages, setMessages] = useState([]);
  const [conversationId, setConversationId] = useState(null);
  const [prompt, setPrompt] = useState('');

  const sendMessage = async () => {
    const response = await fetch('/v1/intelligence/prompt/send', {
      method: 'POST',
      headers: {
        'X-API-Key': apiKey,
        'Authorization': `Bearer ${token}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        conversation_id: conversationId,
        prompt: prompt
      })
    });

    const { data } = await response.json();
    setConversationId(data.conversation);
    setMessages(data.messages);
    setPrompt('');
  };

  return (
    <div>
      <div className="messages">
        {messages.map(msg => (
          <div key={msg.id} className={msg.role}>
            {msg.message}
          </div>
        ))}
      </div>
      <input 
        value={prompt}
        onChange={(e) => setPrompt(e.target.value)}
        placeholder="Ask about trading strategies..."
      />
      <button onClick={sendMessage}>Send</button>
    </div>
  );
}