[Steem Assistant A0.2] Adding personalized Intents for the user's wallet!

in #utopian-io6 years ago (edited)

SteemAssistant-27.png

Steem Assistant (Version A0.2)

commit 5a10cf0

Welcome to the 2nd development update regarding the smart voice interface for the steem blockchain - Steem Assistant. In todays update, the first step towards personalizing this, after all, personal assistant, was made by adding the SteemUser class, as well as 2 intents which can can interact with it - WalletIntent and SpecificWalletIntent. Both of these intents allow you to ask your assistant about your balances, vests, estimated upvote, estimated account value and more.

For now, the Live version uses @ned's account for testing & display purposes, although sometimes this month, a web application utilizing SteemConnect will be launched, allowing you to easily connect your steem assistant to your steem account.

Finally, I want to thank @andrejcibik for the beautiful logo (which you can see at the top of this post) he made for this project, contributing to it at no extra cost.

As always, you can find all of the code over at the github repository, under the MIT License. All feedback and help is more than welcome!

Use it now for absolutely free!

If you want to use the Alpha version for free, just create an Alexa Skill over at developer.amazon.com and set the endpoint to https://steem-assistant.herokuapp.com/steem_assistant ! I'll pay for the server!

New Features

Added a SteemUser class.

By adding this class and 3 methods (calculate_estimated_acc_value, calculate_estimated_upvote and calculate_steem_power), the user is now able to use 2 new intents that allow him to interact with his own wallet, asking for a short summary or by requesting specific information.

Added 3 methods to support the class.
calculate_steem_power
    def calculate_steem_power(self):

        post = '{"id":1,"jsonrpc":"2.0","method":"get_dynamic_global_properties", "params": []}'
        response = session_post('https://api.steemit.com', post)
        data = json.loads(response.text)
        data = data['result']

        total_vesting_fund_steem = float(data['total_vesting_fund_steem'].replace('STEEM', ''))
        total_vesting_shares = float(data['total_vesting_shares'].replace('VESTS', ''))

        sp_dict = {
        "sp_balance" : round(total_vesting_fund_steem * (self.wallet['vests']/total_vesting_shares), 2),
        "delegations" : round(total_vesting_fund_steem * (self.wallet['delegated_vests']/total_vesting_shares), 2)
        }

        return sp_dict
calculate_estimated_acc_value
    def calculate_estimated_acc_value(self):
        response = requests.get("https://api.coinmarketcap.com/v1/ticker/?limit=500")
        data = json.loads(response.text)
        for x in data:
            if x['id'] == "steem":
                steem_price = x['price_usd']
                if float(steem_price) > 1:
                    steem_price = round(float(steem_price),2)
            elif x['id'] == "steem-dollars":
                sbd_price = x['price_usd']
                if float(sbd_price) > 1:
                    sbd_price = round(float(sbd_price),2)

        outcome = round(((self.calculate_steem_power()['sp_balance'] + self.wallet['steem_balance']) * steem_price ) + (self.wallet['sbd_balance'] * sbd_price), 2)

        return str(outcome) + " USD"
calculate_estimated_upvote
    def calculate_estimated_upvote(self):
        reward_fund = s.get_reward_fund()
        sbd_median_price = get_current_median_history_price()
        vests = float(self.session['vesting_shares'].replace('VESTS', '')) + float(self.session['received_vesting_shares'].replace('VESTS', '')) - float(self.session['delegated_vesting_shares'].replace('VESTS', ''))
        vestingShares = int(vests * 1e6);
        rshares = 0.02 * vestingShares
        estimated_upvote = rshares / float(reward_fund['recent_claims']) * float(reward_fund['reward_balance'].replace('STEEM', '')) * sbd_median_price
            
        return estimated_upvote

Added 2 new intents.

WalletIntent

This intent responds with a short summary of the most important information the user might want to know about his wallet. You can try it out by saying Alexa, ask steem about my wallet. See the example below:

image.png

SpecificWalletIntent

This intent responds with specific information about an item requested by the user. The list of supported items currently is: steem, sbd, vests, delegations, upvote, account value, voting power. You can try it out by saying Alexa, ask steem about my steem balance. See the example below:

image.png

Added an get_current_median_history_price function.

This function calculates the current median history price of SBD in the steem blockchain. This allows us to calculate the relation between SP and Vests, amongst other things.

def get_current_median_history_price():
    price = 0.0

    data = '{"id":1,"jsonrpc":"2.0","method":"get_current_median_history_price"}'
    response = session_post('https://api.steemit.com', data)
    data = json.loads(response.text)
    
    if 'result' in data:
        price = float(data['result']['base'].replace('SBD', ''))        
    else:
        raise Exception('Couldnt get the SBD price!')
    
    return price

Roadmap

The current priority is developing personalized Intents & launching an SteemConnect enabled website, which will utilize OAuth2 to allow you to connect your steem username to your assistant.

In the meantime, new Intents will be developed and older Intents will keep being updated to eliminate bugs & speech recognition issues.

How to contribute?

You can contribute to echo.py as well as skill.json directly by creating a Pull Request to my repository, or you can contact me on Discord at Jestemkioskiem#5566 to talk about this project!

I'm looking for Python developers, Web developers and people experienced with handling sensitive information ready to build a website centered about SteemConnect and OAuth2.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.

[utopian-moderator]

Hey @ms10398, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

Amazing, can't wait to see the Google Home port!

Me neither, hopefully it's ready before Summer!

Hey @jestemkioskiem I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Congratulations @jestemkioskiem! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

Coin Marketplace

STEEM 0.19
TRX 0.13
JST 0.030
BTC 63574.15
ETH 3404.81
USDT 1.00
SBD 2.54