AI-Driven Chat Use Cases

    AI-Driven Chat Use Cases

    Use the Desearch API to build chatbots that pull live web and social data into their answers.

    Typical applications:

    • Customer support bots that answer with current information.
    • Virtual assistants for scheduling, recommendations, and general help.
    • Search assistants that surface insights from social media and the web.

    API Endpoints Used

    MethodEndpointDescription
    POSTDesearch AI SearchAI-powered search for real-time interactions.
    POSTDesearch Web Link SearchFetch web results for chatbot logic.
    POSTDesearch X (Twitter) PostsExtract conversations from X (Twitter) posts.
    GETBasic X (Twitter) SearchSimple X (Twitter) searches.
    GETBasic Web SearchGeneral web search.

    Implementation Example

    Basic Endpoint Implementation

    A chatbot that fetches X (Twitter) and web results before answering.

    Step 1: AI-Driven Response with Nova AI Search

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

    Step 2: Fetching X Data for Chatbot Context

    curl
    curl --get --location 'https://api.desearch.ai/twitter' \ --header 'Authorization: dt_<your_api_key>' \ --data-urlencode 'query=AI trends' \ --data-urlencode 'sort=Latest' \ --data-urlencode 'count=20'

    Step 3: Enriching Chatbot Responses with Web Search

    curl
    curl --get --location 'https://api.desearch.ai/web' \ --header 'Authorization: dt_<your_api_key>' \ --data-urlencode 'query=AI future predictions'

    Expected Output

    The chatbot combines results from AI search, X, and the web to build its response.

    Python Scenario Implementation

    A small Python application that combines the three endpoints into one chatbot response.

    python
    import requests API_KEY = "dt_$YOUR_API_KEY" HEADERS = { "Authorization": API_KEY, "Content-Type": "application/json" } def ai_search(prompt): url = "https://api.desearch.ai/desearch/ai/search" payload = { "model": "NOVA", "prompt": prompt, "tools": ["web", "twitter"], "streaming": False } response = requests.post(url, json=payload, headers=HEADERS) return response.json() def X_search(query): url = "https://api.desearch.ai/desearch/ai/search/links/twitter" payload = { "prompt": query, "model": "NOVA", } response = requests.post(url, json=payload, headers=HEADERS) return response.json() def web_search(query): url = "https://api.desearch.ai/desearch/ai/search/links/web" payload = { "prompt": query, "tools": ["web"] } response = requests.post(url, json=payload, headers=HEADERS) return response.json() def chatbot_response(user_query): ai_response = ai_search(user_query) X_response = X_search(user_query) web_response = web_search(user_query) ai_text = ai_response.get("completion", "No AI response found.") X_texts = [tweet.get("text", "") for tweet in X_response.get("miner_tweets", [])][:3] web_texts = [result.get("title", "") for result in web_response.get("search_results", [])][:3] chatbot_reply = f""" 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 if __name__ == "__main__": user_input = input("Ask me anything: ") response = chatbot_response(user_input) print(response)

    How It Works

    1. The chatbot takes user input.
    2. It calls AI search for a summarized answer.
    3. It calls the X endpoint for recent posts.
    4. It calls web search for recent articles.
    5. It combines all three sources into one response.