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

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
 

Ä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

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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 REVIEWERMadyBayot
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
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.pdfsudhanshuwaghmare1
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Kürzlich hochgeladen (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

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