SlideShare a Scribd company logo
1 of 19
Download to read offline
Bot Server Testing
Connection
Lov Kimsrung, 8-June-2022
Flow
What you need!
Googlespreetsheet: This is a list of any bank
servers or any urls which you would like to test a
connection or ping to.
TelegramBot: This would be done by botfather
in telegram. It would act as a human to perform
sending/receiving message and push to telegram
group.
TelegramGroup: We need to create one group
and add all members including the bot to
perform any actions.
Authorizing Google Spreadsheet
1. Google Developers Console: create a
cloud developer account with your
email
2. Create a new project and select that
project to work on
3. Click on APIs & Services
a. Confirm OAuth consent screen
b. Enable APIs & Services: Drive API
and Google Sheet API
c. Create Credential
Choose External for testing mode,
Then fill in info for next pages
Enable APIs & Services
Credentials
There are 3 types of credential:
1. API Keys
2. OAuth Credentials
3. Service Account
Today we’re going to user service
account through pysheets library
since we don’t want to have
refresh token.
Service Account
Keep the key safe!!
TelegramBot
1. Go to telegram and search for
BotFather
2. Start conversation
3. Type /newbot
4. Make sure to keep your token in safe
Link of how to create telegram bot
Enable Permission to Bot
1
3
2
Telegram Group
You just need to add the bot in
your group.
Coding Time
After finish setting up
everything. It’s time to do
coding. In this example we
would like to use Python to
create the application. You can
find the source code in this
gitlab
Authorize Sheet
Remember that we have save the service account json file before. Here is the code snippet of
how we can access googlesheet with that service account using python lib:
def authorization():
# https://pygsheets.readthedocs.io/en/stable/authorization.html
creds = service_account.Credentials.from_service_account_file
(
'/home/dev/open-banking/service-account.json'
,
scopes=('https://www.googleapis.com/auth/spreadsheets'
,
'https://www.googleapis.com/auth/drive'
)
)
Get Data from
Sheet
Add handler for telegram
bot
In this section, we will need a help
from python lib which is called
pyTelegramBotAPI. Actually, there
are many different libs that could do
this.
Keynote for choosing a lib, check
start on lib repository and last
update of that lib.
Server Configuration
In here, we are using ssh(passwordless) to login from one server to another server.
Since targeted server(open banking server) doesn’t have internet connection, we will
run our application on host server which it can access internet in order to push
message to telegram group.
1. Generate private and public keys in host server: ssh-keygen A public key file
“~/.ssh/id_rsa.pub” and a private key file “~/.ssh/id_rsa” will be generated
2. Copy the public key file to the remote machine:
ssh-copy-id remote_username@remote_server_ip_address
3. Login to your server using SSH keys:
ssh remote_username@remote_server_ip_address
Run the application on Server
Setup
● Copy your python files and credential file to server
● Change file_path of credential in python file
Installation with requirements
● sudo apt install python3
● pip3 install -r requirements.txt
Run service in background process
nohup python3 telegram_alert.py start > telegram_alert.log 2>&1 &
** nohup python3 file_name start > log_file_name 2>&1 &
Thanks You

More Related Content

Similar to Testing Connection Between Server to Server with TelegramBot & Googlesheet

Liferay workshop
Liferay workshopLiferay workshop
Liferay workshop
ahmadsayed
 

Similar to Testing Connection Between Server to Server with TelegramBot & Googlesheet (20)

Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
 
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
 
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
 
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
 
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
 
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
 
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
 
Mule ESB integration with Stripe
Mule ESB integration with StripeMule ESB integration with Stripe
Mule ESB integration with Stripe
 
Yes, It's Number One it's TOTP!
Yes, It's Number One it's TOTP!Yes, It's Number One it's TOTP!
Yes, It's Number One it's TOTP!
 
Teams Automation with Graph API
Teams Automation with Graph APITeams Automation with Graph API
Teams Automation with Graph API
 
CGI Presentation
CGI PresentationCGI Presentation
CGI Presentation
 
Introduction to Google Apps Platform
Introduction to Google Apps PlatformIntroduction to Google Apps Platform
Introduction to Google Apps Platform
 
Azure integration in dynamic crm
Azure integration in dynamic crmAzure integration in dynamic crm
Azure integration in dynamic crm
 
Setting up organization with api access
Setting up organization with api accessSetting up organization with api access
Setting up organization with api access
 
Liferay workshop
Liferay workshopLiferay workshop
Liferay workshop
 
The Many Flavors of OAuth - Understand Everything About OAuth2
The Many Flavors of OAuth - Understand Everything About OAuth2The Many Flavors of OAuth - Understand Everything About OAuth2
The Many Flavors of OAuth - Understand Everything About OAuth2
 
Office 365 Authentication Process (oAuth Service Integration) - iXora Tech Se...
Office 365 Authentication Process (oAuth Service Integration) - iXora Tech Se...Office 365 Authentication Process (oAuth Service Integration) - iXora Tech Se...
Office 365 Authentication Process (oAuth Service Integration) - iXora Tech Se...
 
I Love APIs 2015: Crash Course Foundational Topics in Apigee Edge Workshop
I Love APIs 2015: Crash Course Foundational Topics in Apigee Edge WorkshopI Love APIs 2015: Crash Course Foundational Topics in Apigee Edge Workshop
I Love APIs 2015: Crash Course Foundational Topics in Apigee Edge Workshop
 
Automatizacion de Procesos en Modelos Tabulares
Automatizacion de Procesos en Modelos TabularesAutomatizacion de Procesos en Modelos Tabulares
Automatizacion de Procesos en Modelos Tabulares
 
API_Testing_with_Postman
API_Testing_with_PostmanAPI_Testing_with_Postman
API_Testing_with_Postman
 

More from kimsrung lov (7)

Importance of Information Security and Goals for Preventing Data Breaches
 Importance of Information Security and Goals for Preventing Data Breaches Importance of Information Security and Goals for Preventing Data Breaches
Importance of Information Security and Goals for Preventing Data Breaches
 
Code coverage
Code coverageCode coverage
Code coverage
 
Code Smell and Refactoring
Code Smell and RefactoringCode Smell and Refactoring
Code Smell and Refactoring
 
Scrum Events
Scrum EventsScrum Events
Scrum Events
 
JS-formatter
JS-formatterJS-formatter
JS-formatter
 
Google chart
Google chartGoogle chart
Google chart
 
google chart
google chartgoogle chart
google chart
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

Testing Connection Between Server to Server with TelegramBot & Googlesheet

  • 1. Bot Server Testing Connection Lov Kimsrung, 8-June-2022
  • 3.
  • 4. What you need! Googlespreetsheet: This is a list of any bank servers or any urls which you would like to test a connection or ping to. TelegramBot: This would be done by botfather in telegram. It would act as a human to perform sending/receiving message and push to telegram group. TelegramGroup: We need to create one group and add all members including the bot to perform any actions.
  • 5. Authorizing Google Spreadsheet 1. Google Developers Console: create a cloud developer account with your email 2. Create a new project and select that project to work on 3. Click on APIs & Services a. Confirm OAuth consent screen b. Enable APIs & Services: Drive API and Google Sheet API c. Create Credential
  • 6. Choose External for testing mode, Then fill in info for next pages
  • 7. Enable APIs & Services
  • 8. Credentials There are 3 types of credential: 1. API Keys 2. OAuth Credentials 3. Service Account Today we’re going to user service account through pysheets library since we don’t want to have refresh token.
  • 10. TelegramBot 1. Go to telegram and search for BotFather 2. Start conversation 3. Type /newbot 4. Make sure to keep your token in safe Link of how to create telegram bot
  • 11. Enable Permission to Bot 1 3 2
  • 12. Telegram Group You just need to add the bot in your group.
  • 13. Coding Time After finish setting up everything. It’s time to do coding. In this example we would like to use Python to create the application. You can find the source code in this gitlab
  • 14. Authorize Sheet Remember that we have save the service account json file before. Here is the code snippet of how we can access googlesheet with that service account using python lib: def authorization(): # https://pygsheets.readthedocs.io/en/stable/authorization.html creds = service_account.Credentials.from_service_account_file ( '/home/dev/open-banking/service-account.json' , scopes=('https://www.googleapis.com/auth/spreadsheets' , 'https://www.googleapis.com/auth/drive' ) )
  • 16. Add handler for telegram bot In this section, we will need a help from python lib which is called pyTelegramBotAPI. Actually, there are many different libs that could do this. Keynote for choosing a lib, check start on lib repository and last update of that lib.
  • 17. Server Configuration In here, we are using ssh(passwordless) to login from one server to another server. Since targeted server(open banking server) doesn’t have internet connection, we will run our application on host server which it can access internet in order to push message to telegram group. 1. Generate private and public keys in host server: ssh-keygen A public key file “~/.ssh/id_rsa.pub” and a private key file “~/.ssh/id_rsa” will be generated 2. Copy the public key file to the remote machine: ssh-copy-id remote_username@remote_server_ip_address 3. Login to your server using SSH keys: ssh remote_username@remote_server_ip_address
  • 18. Run the application on Server Setup ● Copy your python files and credential file to server ● Change file_path of credential in python file Installation with requirements ● sudo apt install python3 ● pip3 install -r requirements.txt Run service in background process nohup python3 telegram_alert.py start > telegram_alert.log 2>&1 & ** nohup python3 file_name start > log_file_name 2>&1 &