SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
FIDO Alliance
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 

Kürzlich hochgeladen (20)

The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 

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