SlideShare une entreprise Scribd logo
1  sur  15
TwitterBot via AppEngine
   Driven by Google Analytics

   Nirvana Tikku / @ntikku
Context
• Android App – ASOT Unofficial
  – Weekly Trance/Progressive Radio Show
  – Track listings, Play YouTube videos
  – Google Analytics to track usage
  – Parse, AppEngine, YouTube, SoundCloud
  – 15 months, 23K active users
  – >5K plays a day
• Indie developer, free app
Why?
•   Automated social marketing
•   Unleash GA data
•   SEO powered by Twitter
•   Link to interesting content as deemed by visitors
•   Compelling media content music charts
How?
Service. Two Cron jobs, Twitter, Google
Analytics and the AE datastore.

• Seed Tweets – Daily
  – Query GA via Core Reporting API
  – Store necessary elements in datastore

• Publish Tweets – Hourly
  – Tweepy library for auth and publishing
  – ‘Update Status’ with Pending Tweets in datastore
Technical Details
• AppEngine Python Runtime (2.7)
• Libraries used
  –   Tweepy
  –   PyCryptoSignedJWT
  –   OAuth2Client
  –   HTTPLib2
  –   APIClient & URITemplate
• Additional
  – Google Account with OAuth credentials
  – Twitter API key and OAuth credentials
Caveats
• PyCrypto doesn’t play well with PKCS12
  certs – need to use PyCryptoSignedJWT
  library to sign PEM key
• Trying to dereference names to handles
  (i.e. Armin van Buuren -- @arminvanbuuren),
  will most likely get your bot banned 
Code
1. The authentication process
  – Google Analytics API
  – Twitter API
2. Seed tweets via Google Analytics
3. Publish update to Twitter via Tweepy
Google Analytics Authentication
• Google Analytics API
  – Download key (p12)
  – Convert to .pem
  – Add gserviceaccount
    user to GA profile
  – Use PyCryptoJWT
Twitter Authentication
• Twitter API
  – Create App
  – Create OAuth key
  – Copy params
     •   consumer_key
     •   consumer_secret
     •   access_token
     •   access_token_secret
2. Seed tweets via trends in GA


      Query Details
3. Publishing tweets via Tweepy



                 Merge the context with the template



                 Publish the status update
@ASOTbot
• 1 month, 70 followers
  organically

• Utilizes unicode character
  for chart position (1 char)

• Associated with community
  hash tag #ASOT for
  discoverability

• Attaches YouTube video
  youtube.com/watch?v=[videoId]
Recap & DIY
• Clone the ga_twitterbot repo on GitHub
• Go to the Google API Console
   –   Register for Google Analytics
   –   Create a Service Account
   –   Setup the client_id, service_account params
   –   Convert the .p12 key to .pem
• Go to the Twitter API Apps Console
   – Create your app
   – Setup the tw_consumer_key, tw_consumer_secret,
     tw_access_token and tw_access_token_secret params
• Build your GA query via the Google Analytics Query
  Explorer and replace SeedTweetsUtil values
• Set your schedule in cron.yaml
Useful Links
•   Google Analytics Core Reporting API
•   Google Service Accounts
•   Google Analytics Query Explorer
•   Twitter API & Twitter Apps
•   Tweepy Library
•   PyCryptoJWT
•   GitHub project: ga_twitterbot
Thanks

Contenu connexe

Similaire à Google Analytics driven TwitterBot using AppEngine

Building TweetEngine
Building TweetEngineBuilding TweetEngine
Building TweetEngine
ikailan
 
OAuth 2.0
OAuth 2.0 OAuth 2.0
OAuth 2.0
marcwan
 
How to Build, Manage, and Promote APIs
How to Build, Manage, and Promote APIsHow to Build, Manage, and Promote APIs
How to Build, Manage, and Promote APIs
WSO2
 

Similaire à Google Analytics driven TwitterBot using AppEngine (20)

Frappe ERPNext Open Day February 2014
Frappe ERPNext Open Day February 2014Frappe ERPNext Open Day February 2014
Frappe ERPNext Open Day February 2014
 
Building TweetEngine
Building TweetEngineBuilding TweetEngine
Building TweetEngine
 
Adding Identity Management and Access Control to your Application - Exersices
Adding Identity Management and Access Control to your Application - ExersicesAdding Identity Management and Access Control to your Application - Exersices
Adding Identity Management and Access Control to your Application - Exersices
 
Logic apps and PowerApps - Integrate across your APIs
Logic apps and PowerApps - Integrate across your APIsLogic apps and PowerApps - Integrate across your APIs
Logic apps and PowerApps - Integrate across your APIs
 
Watch kit pitfalls. developing iOS app for Dribbble.
Watch kit pitfalls. developing iOS app for Dribbble.Watch kit pitfalls. developing iOS app for Dribbble.
Watch kit pitfalls. developing iOS app for Dribbble.
 
Twitter API, Streaming and SharePoint 2013
Twitter API, Streaming and SharePoint 2013Twitter API, Streaming and SharePoint 2013
Twitter API, Streaming and SharePoint 2013
 
2013.devcon3 liferay and google authenticator integration rafik_harabi
2013.devcon3 liferay and google authenticator integration rafik_harabi2013.devcon3 liferay and google authenticator integration rafik_harabi
2013.devcon3 liferay and google authenticator integration rafik_harabi
 
Building Social Tools
Building Social ToolsBuilding Social Tools
Building Social Tools
 
Social Developers London update for Twitter Developers
Social Developers London update for Twitter Developers Social Developers London update for Twitter Developers
Social Developers London update for Twitter Developers
 
Social Single Sign-On with OpenID Connect
Social Single Sign-On with OpenID ConnectSocial Single Sign-On with OpenID Connect
Social Single Sign-On with OpenID Connect
 
Dev con pnp-engine-presentation
Dev con pnp-engine-presentationDev con pnp-engine-presentation
Dev con pnp-engine-presentation
 
Secure your app with keycloak
Secure your app with keycloakSecure your app with keycloak
Secure your app with keycloak
 
OAuth 2.0
OAuth 2.0 OAuth 2.0
OAuth 2.0
 
Social media analysis in R using twitter API
Social media analysis in R using twitter API Social media analysis in R using twitter API
Social media analysis in R using twitter API
 
How to Build, Manage, and Promote APIs
How to Build, Manage, and Promote APIsHow to Build, Manage, and Promote APIs
How to Build, Manage, and Promote APIs
 
Exploring the Google Analytics API
Exploring the Google Analytics APIExploring the Google Analytics API
Exploring the Google Analytics API
 
Getting notified by SharePoint with the webhook functionality
Getting notified by SharePoint with the webhook functionalityGetting notified by SharePoint with the webhook functionality
Getting notified by SharePoint with the webhook functionality
 
POST/CON 2019 Workshop: Fundamentals
POST/CON 2019 Workshop: FundamentalsPOST/CON 2019 Workshop: Fundamentals
POST/CON 2019 Workshop: Fundamentals
 
Piwik Analytics Platform
Piwik Analytics PlatformPiwik Analytics Platform
Piwik Analytics Platform
 
Develop Windows 8 & Windows Phone apps using crucial Google APIs
Develop Windows 8 & Windows Phone apps using crucial Google APIsDevelop Windows 8 & Windows Phone apps using crucial Google APIs
Develop Windows 8 & Windows Phone apps using crucial Google APIs
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Google Analytics driven TwitterBot using AppEngine

  • 1. TwitterBot via AppEngine Driven by Google Analytics Nirvana Tikku / @ntikku
  • 2. Context • Android App – ASOT Unofficial – Weekly Trance/Progressive Radio Show – Track listings, Play YouTube videos – Google Analytics to track usage – Parse, AppEngine, YouTube, SoundCloud – 15 months, 23K active users – >5K plays a day • Indie developer, free app
  • 3. Why? • Automated social marketing • Unleash GA data • SEO powered by Twitter • Link to interesting content as deemed by visitors • Compelling media content music charts
  • 4. How? Service. Two Cron jobs, Twitter, Google Analytics and the AE datastore. • Seed Tweets – Daily – Query GA via Core Reporting API – Store necessary elements in datastore • Publish Tweets – Hourly – Tweepy library for auth and publishing – ‘Update Status’ with Pending Tweets in datastore
  • 5. Technical Details • AppEngine Python Runtime (2.7) • Libraries used – Tweepy – PyCryptoSignedJWT – OAuth2Client – HTTPLib2 – APIClient & URITemplate • Additional – Google Account with OAuth credentials – Twitter API key and OAuth credentials
  • 6. Caveats • PyCrypto doesn’t play well with PKCS12 certs – need to use PyCryptoSignedJWT library to sign PEM key • Trying to dereference names to handles (i.e. Armin van Buuren -- @arminvanbuuren), will most likely get your bot banned 
  • 7. Code 1. The authentication process – Google Analytics API – Twitter API 2. Seed tweets via Google Analytics 3. Publish update to Twitter via Tweepy
  • 8. Google Analytics Authentication • Google Analytics API – Download key (p12) – Convert to .pem – Add gserviceaccount user to GA profile – Use PyCryptoJWT
  • 9. Twitter Authentication • Twitter API – Create App – Create OAuth key – Copy params • consumer_key • consumer_secret • access_token • access_token_secret
  • 10. 2. Seed tweets via trends in GA Query Details
  • 11. 3. Publishing tweets via Tweepy Merge the context with the template Publish the status update
  • 12. @ASOTbot • 1 month, 70 followers organically • Utilizes unicode character for chart position (1 char) • Associated with community hash tag #ASOT for discoverability • Attaches YouTube video youtube.com/watch?v=[videoId]
  • 13. Recap & DIY • Clone the ga_twitterbot repo on GitHub • Go to the Google API Console – Register for Google Analytics – Create a Service Account – Setup the client_id, service_account params – Convert the .p12 key to .pem • Go to the Twitter API Apps Console – Create your app – Setup the tw_consumer_key, tw_consumer_secret, tw_access_token and tw_access_token_secret params • Build your GA query via the Google Analytics Query Explorer and replace SeedTweetsUtil values • Set your schedule in cron.yaml
  • 14. Useful Links • Google Analytics Core Reporting API • Google Service Accounts • Google Analytics Query Explorer • Twitter API & Twitter Apps • Tweepy Library • PyCryptoJWT • GitHub project: ga_twitterbot