Utilize Datura API to build interactive, AI-driven chatbots capable of understanding and responding to user queries in real-time. This solution is ideal for:

  • Customer Support: Provide instant responses to customer inquiries.
  • Virtual Assistants: Automate scheduling, recommendations, and general assistance.
  • Intelligent Search: Extract insights from social media and web data for real-time updates.

Key Use Cases

Here are the key use cases for the AI-driven chat bots that can be derived from Datura’s API.

Natural Language Understanding (NLU): Enhance chatbots with AI-driven comprehension.

Customizable Responses: Tailor interactions to specific user needs.

Real-Time AI Search: Retrieve insights from X (Twitter), Web, and Reddit data.

Multi-Source AI Analysis: Combine structured and unstructured data for deeper insights.

API Endpoints Used

Here are the endpoints that can be utilized to implement the AI-Driven Chat Use Case.

MethodEndpointDescription
POSTDesearch AI SearchAI-powered search for real-time interactions.
POSTDesearch Web Link SearchFetch web-based insights for chatbot logic.
POSTDesearch X (Twitter) PostsExtract conversations from X (Twitter) posts.
POSTBasic X (Twitter) SearchPerform simple X (Twitter) based searches.
GETBasic Web SearchGeneral web search capabilities.

Implementation Example

Basic Endpoint Implementation

AI Chatbot that fetches real-time X (Twitter) and Web insights.

    curl --location 'https://apis.datura.ai/desearch/ai/search' \
    --header 'Authorization: dt_<your_api_key>' \
    --header 'Content-Type: application/json' \
    --data '{
    "model": "NOVA",
    "prompt": "Latest trends in AI",
    "streaming": true
    }'

Step 2: Fetching X Data for Chatbot Context

    curl --location 'https://apis.datura.ai/desearch/X/search' \
    --header 'Authorization: dt_<your_api_key>' \
    --header 'Content-Type: application/json' \
    --data '{
    "query": "AI trends",
    "date_filter": "PAST_24_HOURS",
    "tools": ["Twitter Search"]
    }'
    curl --location 'https://apis.datura.ai/desearch/web/search' \
    --header 'Authorization: dt_<your_api_key>' \
    --header 'Content-Type: application/json' \
    --data '{
    "query": "AI future predictions",
    "results_limit": 5
    }'

Expected Output

The chatbot receives real-time insights from AI search, X, and Web sources to craft context-aware responses, making interactions more dynamic and informative.

Python Scenario Implementation

A small Python application that integrates Datura API endpoints to build an AI-driven chatbot with real-time responses.

AI-Driven Chatbot with Real-Time Insights

    import requests

    # Datura API Configuration
    API_KEY = "dt_$YOUR_API_KEY"
    HEADERS = {
        "Authorization": API_KEY,
        "Content-Type": "application/json"
    }

    # Function to Fetch AI Search Insights
    def ai_search(prompt):
        url = "https://apis.datura.ai/desearch/ai/search"
        payload = {
            "model": "NOVA",
            "prompt": prompt,
            "streaming": False
        }
        response = requests.post(url, json=payload, headers=HEADERS)
        return response.json()

    # Function to Fetch X (Twitter) Data for Chatbot Context
    def X_search(query):
        url = "https://apis.datura.ai/desearch/X/search"
        payload = {
            "query": query,
            "date_filter": "PAST_24_HOURS",
            "tools": ["Twitter Search"]
        }
        response = requests.post(url, json=payload, headers=HEADERS)
        return response.json()

    # Function to Enrich Responses with Web Search
    def web_search(query):
        url = "https://apis.datura.ai/desearch/web/search"
        payload = {
            "query": query,
            "results_limit": 5
        }
        response = requests.post(url, json=payload, headers=HEADERS)
        return response.json()

    # Function to Generate Chatbot Response
    def chatbot_response(user_query):
        print("🤖 Thinking... Fetching AI insights...")
        ai_response = ai_search(user_query)
        
        print("🔍 Searching X (Twitter) for latest discussions...")
        X_response = X_search(user_query)
        
        print("🌍 Fetching Web insights for better context...")
        web_response = web_search(user_query)

        # Extract Top Insights
        ai_text = ai_response.get("summary", "No AI response found.")
        X_texts = [tweet.get("text", "") for tweet in X_response.get("results", [])][:3]
        web_texts = [result.get("title", "") for result in web_response.get("results", [])][:3]

        # Final Chatbot Response
        chatbot_reply = f"""
        🤖 **AI Chatbot Response**
        🔹 **AI Insight:** {ai_text}
        🐦 **Latest X Discussions:**
        - {X_texts[0] if X_texts else 'No relevant tweets found'}
        - {X_texts[1] if len(X_texts) > 1 else ''}
        - {X_texts[2] if len(X_texts) > 2 else ''}

        🌍 **Web Insights:**
        - {web_texts[0] if web_texts else 'No relevant web articles found'}
        - {web_texts[1] if len(web_texts) > 1 else ''}
        - {web_texts[2] if len(web_texts) > 2 else ''}
        """
        
        return chatbot_reply

    # Example Usage
    if __name__ == "__main__":
        user_input = input("Ask me anything: ")
        response = chatbot_response(user_input)
        print(response)

How It Works

1

User Input

The chatbot takes user input.

2

AI Search

Calls AI search API to get smart insights.

3

X (Twitter) Search

Calls X API to get real-time trends.

4

Web Search

Calls Web search API for latest articles.

5

Manage Response

Combines all three sources to generate an informative chatbot reply.

Use Case Example

User Input: ➡️ “Tell me about the latest AI trends.”

Chatbot Output:

    🤖 AI Chatbot Response
    🔹 AI Insight: AI is revolutionizing business automation with new deep learning models...
    🐦 Latest X (Twitter) Discussions:
    - AI-powered automation is disrupting traditional jobs...
    - Companies are now integrating AI chatbots for real-time support...
    - OpenAI announces a breakthrough in generative AI...

    🌍 Web Insights:
    - "Top AI Trends to Watch in 2025" - TechCrunch
    - "How AI is Reshaping Business" - Forbes
    - "Future of AI: What’s Next?" - MIT Tech Review