4 min read

Documentation for getMetrics Logic

Overview

This node retrieve metrics from specified tweets using their unique identifiers (tweet IDs). It connects to a third-party integration to gather relevant data, processes the inputs, and formats the output, making it an essential tool for users and applications that analyze Twitter data.

Settings

1. tweetIds

2. fields

3. context

How It Works

  1. Input Handling: The logic first extracts the tweetIds and fields either from the provided inputs or from the config. If tweetIds is empty, it returns an error immediately, ensuring that a valid input is always necessary for processing.

  2. Tweet ID Normalization: The logic normalizes the input to ensure that it always operates on an array of tweet IDs. It trims whitespace and filters out any empty strings.

  3. Integration Setup: It uses the a secure connection with the third-party integration based on the given context.

  4. Data Retrieval: It calls the getTweetMetrics method from the integration to fetch metrics for the specified tweet IDs and requested fields.

  5. Error Handling: If any error occurs during the integration call, it captures the error and returns a relevant message.

  6. Output: The function returns the retrieved tweet metrics in the form of an output object, which can then be utilized by the calling process.

Data Expectations

Use Cases & Examples

Use Case 1: Social Media Analysis for Marketing Campaigns

A marketing team wants to analyze the engagement metrics of specific tweets related to their latest product launch to understand how well their audience is responding.

Use Case 2: Public Sentiment Tracking

A data analyst is tasked with monitoring public sentiment towards current events by retrieving metrics from tweets that mention a particular topic or hashtag.

Use Case 3: Historical Data Capture

Researchers studying the influence of social media on public opinion want to retrieve historical metrics on tweets related to significant events.

Example Configuration

For the Social Media Analysis for Marketing Campaigns use case, suppose the team wants to examine the metrics for the following tweet IDs: 12345, 67890. They want to gather the public_metrics and text fields only.

Sample Configuration

json
{
    "inputs": {
        "tweetIds": "12345, 67890",
        "fields": "public_metrics,text"
    },
    "config": {},
    "context": {
        "apiKey": "your_api_key",
        "userId": "your_user_id"
    }
}

Expected Output

If the tweet IDs are valid and the API call is successful, the output may look something like this:

json
{
    "output1": [
        {
            "id": "12345",
            "text": "Excited about the new product launch!",
            "public_metrics": {
                "retweet_count": 50,
                "reply_count": 20,
                "like_count": 100,
                "quote_count": 10
            }
        },
        {
            "id": "67890",
            "text": "Feeling great about our new features!",
            "public_metrics": {
                "retweet_count": 30,
                "reply_count": 15,
                "like_count": 75,
                "quote_count": 5
            }
        }
    ]
}

This example illustrates how the logic can be configured and executed to extract valuable insights from tweets relevant to marketing strategies.