Steem Voice A0.2 - Navigate Steemit using your voice
Steem Voice
Hello everyone! Welcome back to the second development update on the Steem Voice app. This update took the most time because I couldn't get these commands to work properly. For instance, in the first commit, I forgot to enable rich messages which gave me a lot of trouble because I spent a day trying to fix a command that worked the day before. I added this simple line and voila everything was working again:
app.config['ASSIST_ACTIONS_ON_GOOGLE'] = True # To enable Rich Messages
While testing, I found a whole lot of issues that I needed to overcome to get the commands to work properly like getting the thumbnail of a Dtube post ... To keep this post short, I won't be focusing on these issues.
In this update, I wanted to add a way to 'sort of' navigate through Steemit so I added a few commands to do so...
New Features
Altered the last_post
command
To test out some of Google assistant's features I added a button to the last_post command that takes you to your latest post using this simple code:
def r_last_post():
b = Blog(St_username)
user = Steemian(St_username)
post = b.take(1)
resp = ask('Your latest post is: \n'+ post[0]['title'])
postlink = user.bloglink+'/'+post[0]['permlink']
resp.link_out('The post', postlink) # Is used to create a button that takes you to the post
return resp
Here's the command in action :
Added an openblog
command
Using the same process I also added a command to open the user's blog:
def r_trendingposts():
user = Steemian(St_username)
return ask('Click the button below to open your blog').link_out('Blog',user.bloglink)
As you might have noticed I added this one to the Steemian class that I made in the last update like so:
self.bloglink = 'https://steemit.com/@'+St_username # To get the price user's blog link
Here's the command in action :
Added a what's trending
command
At first, I was planning to add this as a simple command that displays the top 8 trending posts then I wanted to add the ability to choose a certain tag. Next, I wanted the app to display the data as a carousel so I needed pictures thus I made this function to do so:
def getpostimg(i): # To get a post's thumbnail
global posts
metadata = posts[i]['json_metadata']
imagedata = json.loads(metadata)
try : # To test if the post is a dtube video
imglink = 'https://snap1.d.tube/ipfs/'+imagedata['video']['info']['snaphash'] # To get the video's thumbnail form d.tube
return(imglink)
except KeyError: # If it's a regular post
try:
return imagedata['image'][0]
except: # If no image is available
return 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/15/No_image_available_600_x_450.svg/320px-No_image_available_600_x_450.svg.png' # a "no image available" picture from Wikimedia
After all that, I added the ability to choose a certain category (trending, hot, new or promoted). Here's the final code:
def r_trendingposts(CTG,Tag):
global posts
if (Tag != '')or (CTG != 'trending'): # If a certain tag is specified or another category -posts- will be reloaded into the top 8 trending posts of that tag
posts = eval('s.get_discussions_by_'+CTG)({"tag":Tag,"limit":"8"})
if Tag == '':
Tag = 'all tags' # To keep a proper resp statment even when no tag is specified
if CTG == 'created':
resp = ask(('Here are the newest posts in %s') % (Tag)).build_carousel()
else:
resp = ask(('Here are the top %s posts in %s') % (CTG,Tag)).build_carousel() # To make a new carousel
for i in range(8): # Add each post to the carousel
try:
resp.add_item(posts[i]['title'],
key=(str(i)), # This key will be used if the user chooses a certain post
img_url=getpostimg(i)
)
except IndexError: # If the available posts are less than 8 (mostly promoted ones)
break
print(resp)
return resp
I also added a follow-up intent that enables the user to open a chosen post:
def r_trendingresp(OPTION):
global posts
OPTION = int(OPTION) # This is the key of the chosen post
postlink = 'https://steemit.com/@'+posts[OPTION]['author']+'/'+posts[OPTION]['permlink']
resp = ask('Click the button below to open the post')
date,time = posts[OPTION]['created'].split('T')
resp.card(title=posts[OPTION]['title'],
text=('A post by %s created on %s at %s' % (posts[OPTION]['author'],date,time)),
img_url=getpostimg(OPTION),
img_alt='test', # This field is required
link=postlink,
linkTitle='Open The post'
)
return resp
Here's the command in action :
The different categories:
Added an openfeed
command
Using the same process I added a command that shows the last 8 posts from the user's feed and I used the same follow-up intent from the previous command to open a chosen post:
def r_feed():
global posts
posts = s.get_discussions_by_feed({"tag":St_username,"limit":"10"})
resp = ask('Here are the latest posts from your feed').build_carousel()
for i in range(10):
try:
resp.add_item(posts[i]['title'],
key=(str(i)), # This key will be used if the user chooses a certain post
img_url=getpostimg(i)
)
except IndexError: # If the available posts are less than 8
break
return resp
Here's the command in action :
Roadmap
This project is still far from being ready. There is a lot to fix, add and to organize but for now, I would rather focus on adding a few more commands. There are lots and lots to be added. All help is appreciated.
How to contribute?
Everyone is welcome to aid. You can contribute to the development of this project by creating a pull request to my repository. You can also get in touch with me on Discord at Fancybrothers#7429 or on Steem.chat at fancybrothers or simply leave your idea down below.
If you want to test this app on your own, contact me and I'll send you the whole Dialogflow agent or a temporarily link to test it out.
My Github account: https://github.com/Fancybrothers
Thank you for your contribution. It's good to see you are continuing working on the project. Since users do not know anything about it, it would be better if you can write how to install it. The code looks great and nicely explained in the contribution.
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
Thank you :) I'll make sure to add that in the next update.
Thank you for your review, @codingdefined! Keep up the good work!
cool)) Steemit users are silent, they love to scroll))
Hi @fancybrothers!
Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server
Hey, @fancybrothers!
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!