Hey there! If you’re looking to keep tabs on what people are saying about your brand on Twitter and analyze the sentiment behind those mentions, you’re in the right place. In this guide, I’ll walk you through setting up an automated workflow that collects Twitter mentions, stores them in Airtable, and performs sentiment analysis using OpenAI’s API. We’ll be using Make (formerly Integromat) to tie everything together. Let’s dive in!
Step-by-Step Guide
1. Set Up Your Twitter Developer Account
First things first, you’ll need access to Twitter’s API:
- Go to the Twitter Developer Portal and log in with your Twitter account.
- Click on “Create Project” and follow the prompts to set up a new project.
- Within your project, create a new app. This will provide you with the necessary API keys and tokens.
- Note down your API Key, API Secret Key, Access Token, and Access Token Secret. You’ll need these later.
2. Create an Airtable Base
Next, set up a place to store your Twitter mentions:
- Log in to Airtable and create a new base.
- Add a table named “Twitter Mentions” with the following fields:
- Tweet ID (Single line text)
- Username (Single line text)
- Tweet Text (Long text)
- Sentiment (Single select: Positive, Neutral, Negative)
- Timestamp (Date and time)
3. Set Up Make (Integromat) Scenario
Now, let’s automate the process:
- Sign in to Make and create a new scenario.
- Add a Twitter module:
- Choose the “Watch Mentions” trigger.
- Connect your Twitter account using the API keys and tokens you obtained earlier.
- Set the desired frequency for checking mentions (e.g., every 15 minutes).
- Add an HTTP module to call OpenAI’s Sentiment Analysis API:
- Choose the “Make a request” action.
- Set the method to “POST”.
- Enter the OpenAI API endpoint URL.
- In the headers, add:
- Authorization: Bearer YOUR_OPENAI_API_KEY
- Content-Type: application/json
- In the body, input the following JSON:
{ "model": "text-davinci-003", "prompt": "Analyze the sentiment of the following tweet: \"{{Tweet Text}}\". Respond with 'Positive', 'Neutral', or 'Negative'.", "temperature": 0, "max_tokens": 10 }
Replace
{{Tweet Text}}
with the actual tweet text from the previous module.
- Add an Airtable module to store the data:
- Choose the “Create a record” action.
- Connect your Airtable account and select the base and table you created earlier.
- Map the fields:
- Tweet ID: ID from the Twitter module.
- Username: Username from the Twitter module.
- Tweet Text: Text from the Twitter module.
- Sentiment: Response from the OpenAI module.
- Timestamp: Created at from the Twitter module.
- Save and activate your scenario.
4. Test Your Workflow
Before going live, it’s crucial to test:
- Manually run the scenario in Make.
- Post a test tweet mentioning your brand.
- Check Airtable to ensure the tweet appears with the correct sentiment analysis.
Optional Enhancements
Once you’ve got the basics down, consider these quick wins:
- Notify Your Team: Add a Slack or email module to alert your team when a negative mention is detected.
- Visualize Data: Use Airtable’s blocks or integrate with a tool like Tableau to create dashboards of sentiment trends over time.
- Respond Automatically: Set up a Twitter module to reply to positive mentions with a thank-you message.
And there you have it! With this setup, you’ll have a pulse on your brand’s Twitter presence and can respond proactively to feedback. Happy automating!