Automated Deployment - AI-Driven Social Media Dashboard

Automated Deployment

Before you launch the automated deployment, please review the architecture, configuration, and other considerations discussed in this guide. Follow the step-by-step instructions in this section to configure and deploy the AI-Driven Social Media Dashboard template into your account.

Time to deploy: Approximately five minutes

Prerequisites

Before you launch this solution, you must have a Twitter consumer key (API key) and secret, and a Twitter access key and secret. If you do not already have these keys, you must create an app in Twitter.

You must also have an Amazon Elastic Compute Cloud (Amazon EC2) key pair. If you do not already have a key pair, see Creating a Key Pair Using Amazon EC2 in the Amazon EC2 User Guide for Linux Instances.

What We’ll Cover

The procedure for deploying this architecture on AWS consists of the following steps. For detailed instructions, follow the links for each step.

Step 1. Launch the Stack

  • Launch the AWS CloudFormation template into your AWS account.

  • Enter values for required parameters: Stack Name, Auth Access Token, Auth Access Token Secret, Twitter Consumer Key, Twitter Consumer Key Secret.

  • Review the other template parameters and adjust if necessary.

Step 2. Build the Queries

  • Build the Amazon Athena queries.

Step 3. Create the Data Source

  • Create the Amazon QuickSight data source.

Step 4. Build the Dashboard

  • Create the Amazon QuickSight dashboard to visualize the data.

Step 1. Launch the Stack

This automated AWS CloudFormation template deploys the AI-Driven Social Media Dashboard on the AWS Cloud. Please make sure that you have completed the prerequisites before launching the stack.

Note

You are responsible for the cost of the AWS services used while running this solution. See the Cost section for more details. For full details, see the pricing webpage for each AWS service you will be using in this solution.

  1. Sign in to the AWS Management Console and click the button below to launch the ai-driven-social-media-dashboard AWS CloudFormation template.

    
                                AI-Driven Social Media Dashboard launch button

    You can also download the template as a starting point for your own implementation.

  2. The template is launched in the US East (N. Virginia) Region by default. To launch the solution in a different AWS Region, use the region selector in the console navigation bar.

    Note

    This solution uses Amazon QuickSight, Amazon Athena, Amazon Translate, Amazon Comprehend and AWS Glue which are currently available in specific AWS Regions only. Therefore, you must launch this solution in an AWS Region where these services are available. For the most current service availability by region, see AWS service offerings by region.

  3. On the Select Template page, verify you selected the correct template and choose Next.

  4. On the Specify Details page, assign a name to your solution stack.

  5. Under Parameters, review the following parameters for the template and modify them, as necessary. This solution uses the following default values.

    Parameter Default Description
    Tweets Configuration
    Twitter Term List <Requires input> A comma-delimited list of terms for which the solution will monitor tweets. For example: 'AWS', 'Amazon'.
    Twitter Languages 'en','es','de','fr','ar','pt' A list of language codes for incoming tweets. Note that the format is single quotation marks and comma separated (for multiple values).
    AWS Environment Parameters
    Application Name AI-Driven-Social-Media The name of the application. This name is used to name or tag resources that the solution creates.
    VPC CIDR Block 10.193.0.0/16 CIDR block for the solution created VPC. You can modify the VPC and subnet CIDR address ranges to avoid collisions with your network.
    Public Subnet 1 CIDR Block 10.193.10.0/24 CIDR block for the solution's VPC subnet created in AZ1.
    Twitter API Parameters
    Auth Access Token <Requires input> The access token used to call Twitter.
    Auth Access Token Secret <Requires input> The access token secret used to call Twitter.
    Twitter Consumer Key <Requires input> The consumer key used to access Twitter.
    Twitter Consumer Key Secret <Requires input> The consumer key secret used to access Twitter.
    Other Parameters
    Instance Key Name <Requires input> Public/private key pair, which allows you to connect securely to the solution's instance after it launches. When you created an AWS account, this is the key pair you created in your preferred region.
    Latest AMI ID /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2 The ID of the latest Amazon Machine Image used for the solution's Amazon EC2 instance.

    Important: Do not change this parameter's default value.

  6. Select Next.

  7. On the Options page, select Next.

  8. On the Review page, review and confirm the settings. Be sure to check the box acknowledging that the template will create AWS Identity and Access Management (IAM) resources resources.

  9. Select Create to deploy the stack.

    You can view the status of the stack in the AWS CloudFormation console in the Status column. You should see a status of CREATE_COMPLETE in approximately five minutes.

Step 2. Build the Queries

  1. Navigate to the Amazon Athena console.

  2. In the navigation pane under Database, select ai_driven_social_media_dashboard.

  3. Use the Athena Query Editor query pane to run queries on the data. The following table contains a list of queries and their descriptions

    Note

    For additional information about the data generated and stored in Amazon Athena, see Appendix B.

    Query Description
    SELECT * FROM tweets limit 10; Returns information for the last 10 tweets.
    SELECT * FROM tweet_sentiments limit 10; Returns sentiment information for the last 10 tweets.
    SELECT * FROM tweet_entities limit 10; Returns entity information for the last 10.
    SELECT type, count(*) cnt FROM tweet_entities GROUP BY type ORDER BY cnt desc Returns a count of the number of entities for each entity type.
    SELECT lang, count(*) cnt FROM tweets GROUP BY lang ORDER BY cnt desc Returns a count of the number of tweets in each language.

Step 3. Create the Data Source

  1. Navigate to the Amazon QuickSight console.

  2. Select Manage data.

  3. Select New data set.

  4. Select Athena.

  5. For Data source name, enter a name (for example, tweet_sentiment) and select Create data source.

    After a few minutes, a success message should appear that shows that the Amazon Athena data imported into Amazon QuickSight.

  6. Select the ai_driven_social_media_dashboard database.

  7. When the list of available tables populates, select the tweet_sentiments table.

  8. Select Edit/Preview Data.

  9. Enter the following custom query to count the distinct tweet IDs:

    SELECT s.*, e.entity, e.type, e.score, t.lang as language, coordinates.coordinates[1] AS lon, coordinates.coordinates[2] AS lat , place.name, place.country, t.timestamp_ms / 1000 AS timestamp_in_seconds, regexp_replace(source, '\<.+?\>', '') AS src FROM ai_driven_social_media_dashboard.tweets t JOIN ai_driven_social_media_dashboard.tweet_sentiments s ON (s.tweetid = t.id) JOIN ai_driven_social_media_dashboard.tweet_entities e ON (e.tweetid = t.id)
  10. Select Finish.

    You should be able to see the sampled data.

  11. In the navigation pane, select Fields, timestamp_in_seconds, Change data type and select Date.

  12. Select Save and Visualize.

Step 4. Build the Dashboard

  1. On the All analyses tab of the Amazon QuickSight start page, choose New analysis. You are taken to the Your Data Sets page.

  2. Choose the data set and then choose Create analysis.

  3. Choose Add on the application bar, and then choose Add visual.

  4. In the Fields list pane, select the drop-down menu and select type and tweetid. If the Fields list isn't visible, choose Visualize to display it.

    The field wells display the fields that are visualized.

  5. Select Field wells to access the options.

  6. In the Fields list pane, drag the tweetids field to the Value field wells.

  7. Select tweetid, Aggregate, Count Distinct.

  8. For Visual types, select the pie chart icon.

    Amazon QuickSight creates the visual.

  9. Select + Add to build the second visual for the dashboard.

  10. Resize the second visual so it matches the size of the first visual and position it next to the first visual.

  11. In the Fields list pane, select the drop-down menu and select sentiment and timestamp_in_seconds.

  12. In the Field wells, zoom either in or out of the time element until hours is shown.

    Amazon QuickSight creates the second visual.

  13. Optional: Open the context menu (right-click) for the neutral line and select Exclude NEUTRAL.

    Do this when there are a disproportionate number of neutral tweets affecting the visual display of the data range of the other tweets.

  14. Select the + Add option to build the third visual for the dashboard.

  15. Position the third visual in the bottom half of the workspace.

  16. For Visual types, select the table icon.

  17. From the Fields list, select the following (to add the translated tweets to the visual):

    • language

    • text

    • originalText

  18. On the toolbar, select Filter.

  19. Select One: language.

  20. Select Custom filter, Does not equal, and enter en.

    Note

    You may need to adjust the column widths in the table view to see the last column.

Now you can view graphical representations of your tweet entities, tweet sentiment over time, and translated tweets.

You can create additional visuals to create a more robust visualization of your tweet data.