Skip to content

An NLP application built using Spring Boot that uses the Twitter and OpenAI APIs to summarise the tweets published by an user

Notifications You must be signed in to change notification settings

ahmedmq/boot-twitter-ai-summary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Twitter OpenAI Summary

This is a Spring Boot application that uses the Twitter API to get the latest tweets published by a user and then uses the OpenAI API to summarize the tweets in terms of the content, topics and sentiment. This repo is an inspiration from the should-i-follow project.

recording

Twitter API

The app uses the following Twitter APIv2 endpoints

API Description
POST https://api.twitter.com/oauth2/token Generate an access token (Bearer token) for app only
GET https://api.twitter.com/2/users/by/username/{username} User details lookup by username
GET https://api.twitter.com/2//users/{id}/tweets Tweets published by a specific Twitter account. Uses the default of maximum 10 tweets

Twitter API authentication uses application-only technique. The app generates an App only access token(Bearer token) by passing the Twitter consumer key and consumer secret to the /token/oauth endpoint.

Get access to the Twitter API by following the steps mentioned here. The API docs can be found here

OpenAI API

The app uses the following OpenAI API endpoints

API Description
POST https://api.openai.com/v1/chat/completions Creates a completion for the chat message

The OpenAI API uses API keys for authentication. Visit your API Keys page to retrieve the API key. The API docs can be found here

Running the app

  • Define the following environment variables

     export TWITTER-CONSUMER-KEY=<your-twitter-consumer-key>
     export TWITTER-CONSUMER-SECRET=<your-twitter-consumer-secret>
     export OPENAI-API-KEY=<your-openai-api-key>
  • Start the application from the console by entering the command from the root of the project

    ./mvnw spring-boot:run

    Access the application at http://localhost:8080

About

An NLP application built using Spring Boot that uses the Twitter and OpenAI APIs to summarise the tweets published by an user

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published