SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Semelhante a Google Analytics driven TwitterBot using AppEngine

Frappe ERPNext Open Day February 2014
Frappe ERPNext Open Day February 2014Frappe ERPNext Open Day February 2014
Frappe ERPNext Open Day February 2014rushabh_mehta
 
Building TweetEngine
Building TweetEngineBuilding TweetEngine
Building TweetEngineikailan
 
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Álvaro Alonso González
 
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 APIsSriram Hariharan
 
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.Agilie Team
 
Twitter API, Streaming and SharePoint 2013
Twitter API, Streaming and SharePoint 2013Twitter API, Streaming and SharePoint 2013
Twitter API, Streaming and SharePoint 2013Sebastian Huppmann
 
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_harabiRafik HARABI
 
Building Social Tools
Building Social ToolsBuilding Social Tools
Building Social ToolsAnand Hemmige
 
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 Angus Fox
 
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 ConnectJames Melville
 
Dev con pnp-engine-presentation
Dev con pnp-engine-presentationDev con pnp-engine-presentation
Dev con pnp-engine-presentationGautam Sheth
 
Secure your app with keycloak
Secure your app with keycloakSecure your app with keycloak
Secure your app with keycloakGuy Marom
 
OAuth 2.0
OAuth 2.0 OAuth 2.0
OAuth 2.0 marcwan
 
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 Mohd Shadab Alam
 
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 APIsWSO2
 
Exploring the Google Analytics API
Exploring the Google Analytics APIExploring the Google Analytics API
Exploring the Google Analytics APIVanessa Sabino
 
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 functionalityElio Struyf
 
POST/CON 2019 Workshop: Fundamentals
POST/CON 2019 Workshop: FundamentalsPOST/CON 2019 Workshop: Fundamentals
POST/CON 2019 Workshop: FundamentalsPostman
 
Piwik Analytics Platform
Piwik Analytics PlatformPiwik Analytics Platform
Piwik Analytics Platformpiwik
 
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 APIsIsham Mohamed Iqbal
 

Semelhante a 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
 

Último

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Último (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

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