This is an exercise , using a dummy idea to produce a POC of a feature.
Check it out the Twitter bot
A few days ago , I saw this tweet
In this tweet , written in portuguese, is stated that a popular brazilian saying is easily created, following a set of rule:
- The phrase must start with a animal name
- Folowed by an adjective to the animal
- Add the word no
- Followed by a verb
- And finished with an adverb of time, place or mood.
This set of rules got me thinking and I've created this application , with hardcoded data to generate completely random strings for each rule.
Head over to Twitter engine directory
cd ./twitter-engine
You need to create a env file in order to generate the frases from OpenAI
, and to create tweets:
touch .env
Add your key within the enviroment variable: OPENAI_API_KEY
Check how to create your own OpenAI
key here
Add your Twitter
keys as TWITTER_CONSUMER_KEY
, TWITTER_CONSUMER_SECRET
, TWITTER_ACCESS_TOKEN_KEY
, TWITTER_ACCESS_TOKEN_SECRET
Check how to create your own keys here
Your file should have the variables as follow:
OPENAI_API_KEY="your key"
TWITTER_CONSUMER_KEY="your key"
TWITTER_CONSUMER_SECRET="your key"
TWITTER_ACCESS_TOKEN_KEY="your key"
TWITTER_ACCESS_TOKEN_SECRET="your key"
yarn
or
npm install
npm run dev
# or
yarn dev
There you have it, the application will generate the image at ./src/public/images
and try to send it to twitter according to node-cron
schedule on ./src/app.ts
Head over to Nextjs engine directory
cd ./frontend-engine
Install with npm install
or yarn
You need to create a env file in order to generate the frases from OpenAI
:
touch .env.local
Add your key within the enviroment variable: NEXT_PUBLIC_OPENAI_API_KEY
Your file should have the variables as follow:
NEXT_PUBLIC_OPENAI_API_KEY="your key"
Check how to create your own OpenAI
key here
npm run dev
# or
yarn dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying pages/index.js
. The page auto-updates as you edit the file.
The pages/api
directory is mapped to /api/*
. Files in this directory are treated as API routes instead of React pages.
There you have it, the application will generate the image at http://localhost:3000
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.