n8n

How to Automate Twitter to Slack Sentiment Alerts?

Start your day with a quick look at what people say on social media. Every morning, the system finds new tweets for a chosen hashtag and highlights the positive ones for your team. It helps marketing teams spot ideas and plan posts fast.

At 6 each day, a schedule runs a Twitter search for #OnThisDay and pulls up to three results. The tweet text is saved in MongoDB, then scored by Google Cloud Natural Language for sentiment and magnitude. The results are mapped and stored in a PostgreSQL table so you can track history and build reports. An IF check looks at the score and posts only positive items to a Slack channel, while neutral or negative items are skipped.

You need access to Twitter, MongoDB, PostgreSQL, Slack, and Google Cloud Natural Language. After connecting each account, set your keyword, channel, and database details. Expect less manual scanning and fewer errors, plus a clean dataset you can use for weekly insights and content planning. You can change the schedule, the search term, and the message format to fit your team workflow.

What are the key features?

  • Daily schedule runs at 6 using a Cron trigger to keep timing consistent.
  • Twitter search pulls up to three tweets for the #OnThisDay keyword.
  • MongoDB stores raw tweet text so you keep an unmodified record.
  • Google Cloud Natural Language scores sentiment and magnitude for each tweet.
  • Mapped fields prepare clean text, score, and magnitude for storage.
  • PostgreSQL saves structured results for reporting and trend analysis.
  • IF filter posts only positive tweets to a Slack channel for quick team review.
  • NoOp branch safely ignores neutral or negative items without stopping the run.

What are the benefits?

  • Reduce daily social scanning from 20 minutes to 2 minutes
  • Automate 80 percent of monitoring work with scheduled search and alerts
  • Improve data quality by reducing copy and paste errors by 90 percent
  • Connect five systems in one flow for a clear view of results
  • Scale to more keywords and higher volume without extra manual effort

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Twitter, MongoDB, PostgreSQL, Slack and Google Cloud Natural Language. See the Tools Required section above for links to create accounts with these services.
  3. Open the Cron node and set the schedule to your local time. For quick testing, switch to Every Minute, then change it back to your daily time.
  4. Double click the Twitter node, choose the search operation, and confirm the search term is #OnThisDay with a limit of 3. In the Credential dropdown, click Create new credential and follow the on screen steps to connect your Twitter developer app.
  5. Double click the MongoDB node. In the Credential dropdown, click Create new credential and enter your connection string, database, and authentication details. Set the collection to tweets.
  6. Open the Google Cloud Natural Language node. In the Credential dropdown, click Create new credential and follow the on screen steps. Use your Google Cloud project with the Natural Language API enabled. Service account JSON or OAuth works.
  7. Open the Set node and confirm it maps documentSentiment.score to score and documentSentiment.magnitude to magnitude, and passes the text field.
  8. Double click the PostgreSQL node. Create a new credential with your host, port, database, user, and password. Make sure the table name is tweets and the columns are text, score, and magnitude.
  9. In your PostgreSQL database, create the table if it does not exist: CREATE TABLE tweets (id SERIAL PRIMARY KEY, text TEXT, score NUMERIC, magnitude NUMERIC, created_at TIMESTAMP DEFAULT NOW());
  10. Open the IF node and confirm it checks that the score is larger than 0. Adjust the threshold if your team wants only strongly positive posts.
  11. Double click the Slack node. Create a new credential by clicking Create new credential and follow the on screen steps to authorize Slack. Set the channel to tweets and review the message template.
  12. Run a test by setting Cron to Every Minute and clicking Execute Workflow. Confirm new documents in MongoDB, new rows in PostgreSQL, and Slack messages for positive tweets.
  13. If no messages appear, widen the search term or increase the Twitter limit. If database writes fail, check firewall or network access and verify table and column names.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Google Cloud Natural Language

Sign up

Free: first 5,000 units / mo for Entity Analysis; then $0.001 per 1,000 characters

MongoDB

Sign up

Atlas Free (M0): $0 / mo (free forever)

PostgreSQL

Sign up

Free: $0 (open-source PostgreSQL License; self-hosted)

Slack

Sign up

Free plan: $0 / mo; limited to 10 apps (third-party or custom) and usable via Slack API

Twitter

Sign up

Free tier: $0 / mo, 500 posts / mo and 100 reads / mo (X API v2)

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.