Greed – Telegram Shopping Bot

Greed is an e-commerce bot running on Telegram. It allows users to chat with it to purchase goods and pay for them in bitcoin

Resources

Source Codehttps://github.com/DarrenWestwood/greed
Youtube Videohttps://www.youtube.com/watch?v=riRFU4OYPoU

Requirements

  • Telegram Account
  • Linux System
  • Python 3.8
  • Git

Initial Setup

The code repository of the Telegram Bot integrated with Blockonomics payments is available on GitHub here. The step-by-step instructions on how to integrate Blockonomics payments are provided in the README of the repository, for installation of the greed customizable bot, you have to visit the main greed project repository’s README file and follow the steps.

Creating Bot Token

The Telegram Bot token can be obtained by creating a new bot using the BotFather in Telegram. Search for BotFather in Telegram and start the bot. It will provide various options for managing and creating bots. Create a new bot using the /newbot command. It will ask for details about the bot, such as the bot name and username. Fill in the information accordingly. Once the bot has been created the API TOKEN for the bot will be provided. Copy the token and provide it in the config/config.toml file in the token field.

Integrating Blockonomics

Once the bot token has been specified, the bot can be started by using the python -OO core.py . To integrate Bitcoin payments with the bot an API_KEY is required from Blockonomics, you can find the API_KEY in  Blockonomics Merchants > Stores. If you don’t have an account create one it is completely FREE. Copy the API Key and paste it into the Blockonomics section API_KEY field in config/config.toml below the API_KEY field, there is a SECRET_KEY field which is a custom string provided by you. Remember the SECRET_KEY which is created by you. It will be used for CALLBACK_URLS.

Setting Up Callback URL

HTTP Callback URL’s are responsible for verifying payments and updating payment status. Whenever a payment changes status, the Callback URLs are called with the updated status. Now let us set up a Callback URL for our website. To set up the Callback URL, you need to deploy your bot on the live internet. For that, we need to obtain the test callback API provided by Blockonomics. Now copy the Forwarding URL from the README of the blockonomics greed project in Github. For setting up HTTP Callback you need to have a store on the Blockonomics website. You can create one from  Blockonomics >Merchants > Stores. In the HTTP Callback URL field, provide the copied URL from the Blockonomics test callback API, followed by /callback?secret=SECRET_KEY here the secret key is the key which I told you to remember, it can be found in the config/config.toml file.

Start Testing your Bot

Hurray! After completing these steps you have successfully created a Telegram Bot Shop Which accepts Bitcoin Payments as well. Start your bot in Telegram, if you can’t find your bot you can find it using BotFather using /mybots the command which will list all your bots. You will be the manager of the bot, and you can add Products from the Manager Account, if you want to check the working of Bitcoin payments you can Switch to the Customer Mode from the panel and add funds to your wallet using BITCOIN. For Testing purposes, you can make use of the Log/Test Bench provided by Blockonomics for making mock payments. In the Test bench, Select the store to provide the BTC amount and Bitcoin Address copied from the Telegram Bot Shop, and select any of the payment statuses for testing. Once the test payment is sent you can see your wallet will be funded with the corresponding BTC amount.

The End

We have successfully created a Telegram Bot Shop with the help of Greed ( Customizable Bot Shop) which will accept Bitcoin Payments and we also learned how to configure the Callback URL for the Store and make test payments for the Store.