Search Tweets
Purpose
This node enables users to perform a recent tweet search using specified parameters. It connects to a Twitter integration, allowing retrieval of tweets based on a defined query. This component is suitable for use cases related to social media analytics, sentiment analysis, and real-time monitoring of discussions on various topics.
Settings
The searchTweets component has several configurable settings that allow users to customize the behavior and appearance of the logic.
1. Query
- Input Type: String
- Description: The search term or phrase that the user wants to look for in recent tweets. This setting is crucial as it determines the tweets that will be fetched. If left empty, the component will return an error.
- Default Value: The default is an empty string.
2. Fields
- Input Type: String or Array
- Description: Specifies which fields of the tweet data to return in the response. Acceptable fields include
id,text,created_at,public_metrics,author_id,source, andlang. Users can either provide a string of comma-separated field names or an array of field names. Modifying this setting affects the amount of data returned, allowing users to tailor the response to their needs. - Default Value:
id,text,created_at,public_metrics,author_id,source,lang
3. Max Results
- Input Type: Numeric
- Description: Determines the maximum number of results (tweets) to be fetched in a single query. Adjusting this setting affects the volume of data returned. A higher number increases the amount of information but may affect performance if too many results are requested.
- Default Value: 10
4. Next Token
- Input Type: String (optional)
- Description: Used for pagination. If there are more results available than can be returned in a single response, this token retrieves the next set of results. Leaving this field undefined fetches only the initial set of results.
- Default Value:
undefined(no pagination applied by default)
How It Works
- The component begins by destructuring the input parameters:
inputs,config, andcontext. - It retrieves values for each of the settings:
query,fields,maxResults, andnextToken, prioritizing user inputs over default settings. - A validation check is performed to ensure that the
queryis provided. If not, it returns an error indicating that a search query is required. - The logic then builds a connection instance using a secure connection, passing it the context.
- The integration attempts to search for recent tweets using the specified parameters:
query: The search term.fields: The fields of data to return.maxResults: The maximum number of tweets to fetch.nextToken: Optional token for pagination.
- If successful, it captures the data and returns it in a structured format. If there is an error during the integration call, it provides a relevant error message.
Data Expectations
The searchTweets component expects the following data inputs:
- Query: A valid string representing the search term.
- Fields: A string or array specifying which fields of the tweet should be returned.
- Max Results: A positive numeric value that indicates the number of tweets to retrieve (default is 10).
- Next Token: A string used for pagination; no default value.
Use Cases & Examples
Use Case 1: Social Media Monitoring
A marketing team can use the searchTweets component to track mentions of their brand on Twitter and assess public sentiment over time.
Use Case 2: Event Tracking
An event organizer can leverage the component to fetch real-time tweets during an unfolding event (e.g., a conference or concert) to analyze attendee feedback.
Use Case 3: Trend Analysis
Data analysts may wish to examine recent tweets concerning specific hashtags to identify trending topics and sentiment.
Example Configuration
For the Event Tracking use case, a configuration might look like this:
{
"inputs": {
"query": "#VantageConference",
"fields": ["id", "text", "created_at", "author_id"],
"maxResults": 20,
"nextToken": undefined
},
"config": {}
}In this example, the component is set to search for tweets with the hashtag #VantageConference, returning the tweet ID, text, creation date, and author ID, with a limit of 20 results.