This application uses the Twitter API to get tweets representing the SEARCH_TERM
in app.js
. Then it sends the tweets through the Watson Natural Language Understanding service to get a sentiment score for each tweet.
The SEARCH_TERM
is meant to be updated locally so you can experience the real time hot reloading development experience that Kabanero provides (when code is changed and the file is saved).
Note: This repository is already initialized with the Kabanero Node.js Express v0.2.5
Collection by using the appsody init
command.
- Appsody CLI
- A Watson NLU service instance
- Create a Watson NLU instance
- There is a free "lite" plan available
- On the NLU Dashboard, view the Service Credentials and click View Credentials
- Note the
apikey
and theurl
because you will need them for your.env
file
- Note the
- Create a Watson NLU instance
- A Twitter Developer account
- Create a twitter developer account
- Create a Twitter app to get the API keys required for this application.
- In the app click Keys and tokens and take a note of all 4 values. You will need these for your
.env
file.
- In the app click Keys and tokens and take a note of all 4 values. You will need these for your
- Clone this repository
git clone git@github.com:alohr51/Kabanero-Watson-Twitter-Example.git
- On the repository root create a file called
.env
and copy and paste the below content into the file. Be sure to replace the<XX_XX_XX>
values with your credentials noted from the Prereqs step above. Do not commit this file to git.
TWITTER_CONSUMER_KEY=<YOUR_TWITTER_CONSUMER_KEY>
TWITTER_CONSUMER_SECRET=<YOUR_TWITTER_CONSUMER_SECRET>
TWITTER_ACCESS_TOKEN_KEY=<YOUR_TWITTER_ACCESS_TOKEN_KEY>
TWITTER_ACCESS_TOKEN_SECRET=<YOUR_TWITTER_ACCESS_TOKEN_SECRET>
NLU_URL=<YOUR_NLU_URL>
NLU_API_KEY=<YOUR_NLU_API_KEY>
-
Using the Appsody CLI we can run the app and start the development experience
- In a terminal make sure you are at this repositories root
- Run the command:
appsody run --docker-options "--env-file .env"
- The
--docker-options
flag will pass along the options to thedocker run
command, this includes telling Docker about our env file. Docker will set these env variables for us on start. - Learn More about the appsody run command.
- The
-
In the output from the
appsody run
command, Appsody will tell you what port the application was started on.- For example:
[Container] App started on PORT 3000
means you can access your app in your browser atlocalhost:3000
- Give the app a second to load (it does the API requests on load)
- For example:
Go change the SEARCH_TERM
in app.js
and save the file, you will notice Appsody will restart your container with updated code right away. Go ahead and refresh your browser and you will see results from your new search term.
Appsody is only a part of Kabanero, but it is the main development experience associated with Kabanero. To learn more, please visit Kabanero.io.