Easy as 1-2-3!
📅 August 17, 2023
While we don’t typically feature these kinds of bots on Botwiki, this is still a fun introduction to the world of botmaking. And with Pipedream, it’s super easy, with very little “coding” necessary.
Yo, we got you. #bots
(Thanks to @thzinc for the updated image!)
First, we’ll need to create a new Mastodon account for our bot and get our access token. We will also need to set up an account on Pipedream. Now we can connect our bot account inside Pipedream. We’ll search for “mastodon” and follow the instructions on adding our domain and token.
Next, let’s head over to the workflow dashboard and create a new workflow.


Choose Schedule and Custom Interval as a trigger for the bot. (Here are some tips on how often your bot should post.)

Next, we’ll add a Python code block that will run every time our scheduler is triggered.


This is where we can put our quotes, and a few lines of code that will pick a random one from our list.
import random
def handler(pd: "pipedream"):
quotes = [
{
"quote": "Time you enjoy wasting is not wasted time.",
"author": "Marthe Troly-Curtin"
},
{
"quote": "You only live once, but if you do it right, once is enough.",
"author": "Mae West"
},
{
"quote": "I finally figured out the only reason to be alive is to enjoy it",
"author": "Rita Mae Brown"
},
{
"quote": "Never be afraid to sit awhile and think.",
"author": "Lorraine Hansberry"
},
{
"quote": "We can do anything we want to if we stick to it long enough.",
"author": "Helen Keller"
}
]
quote = random.choice(quotes)
print(quote)
return {"quote": quote}
If you’d like to use lyrics, you will want to split them into multiple lines using triple quotes. Here’s what that would look like.
import random
def handler(pd: "pipedream"):
quotes = [
{
"quote": """
Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
""",
"author": "Rick Astley"
}
]
quote = random.choice(quotes)
print(quote)
return {"quote": quote}
Now we just need the Mastodon step that will post our random quote.

Look for “post status”.

Under “Mastodon Account”, choose the account you added earlier, and for value, use:
{{steps.quotes.$return_value.quote.quote}}\n— {{steps.quotes.$return_value.quote.author}}
Note the \n
used to add a line break in your message.
If you’d like to include more fields, like the year, or the name of a book the quote is from, you can simple add this information to the list of your quotes inside the Python block:
{
"quote": "Time you enjoy wasting is not wasted time.",
"author": "Marthe Troly-Curtin",
"source": "Phrynette Married",
"year": 1911
}
And your “value” will then look like this.
{{steps.quotes.$return_value.quote.quote}}\n— {{steps.quotes.$return_value.quote.author}} ({{steps.quotes.$return_value.quote.source}}, {{steps.quotes.$return_value.quote.year}})

Make sure to also enable the option to split long messages into a thread.
Now let’s test our workflow.



Looking good!
Now you can click the Deploy button in your workflow to publish it. And there you have it, your very own quote bot. Here’s the finished workflow for reference. If you get stuck at any point, feel free to join the Botmakers Slack group and ask for help.
And if you’d like to see what else you can do with Pipedream, I have a series of tutorials on my blog.
I hope you enjoyed the tutorial, and until next time!
Enjoyed the tutorial?
Consider supporting Botwiki!
Latest from the blog

Eight years of Botwiki, and 2,000 bots
Happy birthday, Botwiki!

Cheap Bots, Done Quick suspended, this time for good
So long, and thanks for all the bots.

Twitter shutting down free access to their API on February 9
I keep saying it's an end of an era quite often these days.