> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agent.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Analyze Contact Email History & Insights

> Search a contact's email history for relevant discussions, extract interaction patterns, timelines, and generate actionable insights based on contact and meeting details.



## OpenAPI

````yaml /api-reference/v1/v1.1.0_openapi.json post /action/fetch_relevant_gmail_threads
openapi: 3.0.0
info:
  version: 1.1.0
  title: AI Actions - Get Data
  description: API specifications for 'Get Data' category AI actions.
  license:
    name: MIT
servers:
  - url: https://api-lr.agent.ai/v1
security:
  - bearerAuth: []
paths:
  /action/fetch_relevant_gmail_threads:
    post:
      tags:
        - Integration Intelligence
      summary: Analyze Contact Email History & Insights
      description: >-
        Search a contact's email history for relevant discussions, extract
        interaction patterns, timelines, and generate actionable insights based
        on contact and meeting details.
      operationId: fetchRelevantGmailThreads
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email_provider:
                  type: string
                  enum:
                    - gmail
                    - outlook
                  description: Email service to search. Supports Gmail and Outlook Mail.
                  default: gmail
                contact_email:
                  type: string
                  description: >-
                    The email address to search for (e.g., john@example.com).
                    Will search in from, to, and cc fields.
                meeting_topic:
                  type: string
                  description: >-
                    Topic or keywords to search for in emails (e.g., 'Q4 pricing
                    proposal'). AI will extract relevant keywords.
                date_range_days:
                  type: string
                  enum:
                    - '1'
                    - '7'
                    - '30'
                    - '90'
                  description: How far back to search for emails.
                  default: '90'
                max_results:
                  type: string
                  description: >-
                    Maximum number of email threads to retrieve (e.g., 10, 50,
                    100).
                  default: '10'
                  pattern: ^[0-9]+$
                analysis_type:
                  type: string
                  enum:
                    - none
                    - timeline
                    - insights
                  description: Optional AI analysis to run on the fetched emails.
                  default: none
                output_variable_name:
                  type: string
                  description: >-
                    Provide a variable name to store the Gmail threads, like
                    'topic_relevant_gmail_threads' or 'contact_emails'.
                  default: topic_relevant_gmail_threads
                  pattern: ^[a-zA-Z][a-zA-Z0-9_]*$
              required:
                - email_provider
                - date_range_days
                - max_results
                - analysis_type
                - output_variable_name
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResponse'
        '401':
          description: Unauthorized - invalid or missing bearer token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResponse'
components:
  schemas:
    ActionResponse:
      type: object
      properties:
        status:
          type: integer
          format: int32
          description: HTTP status code of the action response
        response:
          type: object
          description: Response data from the action
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer token from your account
        ([https://agent.ai/user/integrations#api](https://agent.ai/user/integrations#api))

````