Scheduled Twitter Threads (Scett) - Appwrite x DEV Hackathon
Tags: appwritehack, appwrite, twitter
Published: 2022-05-12 22:17:40

---
title: Scheduled Twitter Threads (Scett) - Appwrite x DEV Hackathon
published: true
description: My submission to the Appwrite Hackathon on DEV!
tags: appwritehack, appwrite
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xmrbxn5lqo1zqbif9ql.png
---

### Overview of My Submission

I've never been a big Twitter user (social media at large), but that trend has changed since I discovered the world of technical writing.

I also discovered that, timely updates to most services I use are posted on Twitter, when they are down, back up, announcing new updates etc.

Also, many developers use it to share knowledge snippets (that I find useful) and their cool new programming endeavors.

**We get your point, it is the Developers' town square, so what's all this about?**

Well, in the spirit of sharing knowledge, and being inspired by a "currently" [hobby project](https://dev.to/xinnks/my-daily-reads-tailored-dev-content-delivered-to-your-inbox-3ak0) that I submitted to the [first Dev Hackathon this year](https://dev.to/devteam/announcing-the-mongodb-atlas-hackathon-on-dev-4b6m). I decided to set up a Twitter account that shares Dev Community content (soon to add content from other dev platforms) to the Twitter dev community, mainly beginner content.

I thought of setting up a bot to do the posting, but figured, it would lack a human touch as a bot would just post the same garbage it received.

I obtained daily dev content per the targeted languages set up on [my-daily-reads](https://mdr.jamesinkala.com) and would filter them, add a human touch then post them.

Threads have been a big help, but a disappointment as well.
They are useful since I can compile posts then post them together, but the fact that I can't schedule them (since I am sometimes busy, or lazy) has been a set back.

To counter this problem, I've been storing drafts on Twitter's mobile app, then manually post the threads at the desired time. A very crude hack in the current state of tech.

I would assume to understand why Twitter wouldn't add scheduled tweets as a feature, something along the lines of needing people to be actively engaging in the platform and scheduled tweets will be antithetical to that model. (Maybe they have it exclusive to blue check-marks? Anybody?)

So, to entice my lazy (or productive) habits, I decided to create an app that enables me (and anyone else who'd favor) to schedule Twitter threads.

And what better way is there to do it than while learning a new technology, Appwrite in this case.

<center><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jvlun80nginsg7mm5u46.png" height="100" width="100" alt="Scett" ></center>

## Building Scett
- Install [Docker](https://www.docker.com/products/docker-desktop)
- Install [Appwrite](https://appwrite.io/docs).

### Setting up Twitter
To be able to send Tweets using the Twitter's API you need to register for a [Twitter developer account](https://developer.twitter.com).

After passing through the verification process for creating a Twitter Dev account, inside the developer dashboard add an app and fill in the necessary details.
 Store the app id somewhere.

Inside your new app add enable OAuth 1.0a user authentication settings, choose the **read and write permissions** as Scett will be posting on behalf of Twitter users. Store the API Key, API Key Secret and Bearer Token somewhere safe as we'll be using them later.

Provide the required **Callback URI / Redirect URL** as well as the **Website URL**, well be needing the callback URI in the process of authenticating users in Scett.
In the case of the front-end in [Scett's Github repo] we are using - *DOMAIN/twauth*.

Add other information such as the app's description and and logo to help users know what it's about.

### Setting Up Appwrite

Create a new Appwrite project and add a web platform.

#### Collections
Add the following collections with the respective attributes.

__threads__
   
 Name | Type | Required |
 --- | --- | --- |
 title | String | true |
 postTime | Integer | true |
 Tweets | String[]  |  |
 userID | String  | true | 

Permissions:
- Read: `role:member`
- Write: `role:member`

&nbsp;

__twitterInfo__
   
| Name | Type | Required|
| ---- |:------:| -----:|
| handle | String | true |
| token  | String | true |
| id | String  | |
| userID | String  | true |

Permissions:
- Read: `role:member`
- Write: `role:member`

&nbsp;

![Scett Collections](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s28jug7sye771ghd4dpj.png)


#### Functions

Add two functions and create api keys for them respectively.

The functions code is included within the project's repository.

##### Twitter Oauth
This function will be used in the Twitter's oauth 3-legged flow for user authentication.
Its API key only needs the execute permission.
Add the following environmental keys to this function.
   - __ENCRYPTION_SECRET__ - a 32 character String which will act as the salt to encrypting our user tokens. We will be encrypting the tokens before saving them to the twitterInfo collection.
   - __TW_OAUTH_FUNCTION_API_KEY__ - Api key we generated for this function.
   - __TWITTER_AUTH_REDIRECT_ENDPOINT__
   - __TWITTER_API_KEY__ - Obtained from out twitter app.
   - __TWITTER_API_KEY_SECRET__ - Obtained from out twitter app.

##### Tweets Envoyer
   This function will be used in the Twitter's oauth 3-legged flow for user authentication.
   Its API key needs document read and right and function execution permissions.
   Add the following environmental keys to this function.
   - __ENCRYPTION_SECRET__ - Same as above
   - __TW_ENVOYER_FUNCTION_API_KEY__ - Api key we generated for this function.
   - __TWITTER_API_KEY__ - Same as above
   - __TWITTER_API_KEY_SECRET__ - Same as above
   - __TWITTER_INFO_COLLECTION_ID__ - Collection id of our twitterInfo collection
   - __APPWRITE_ENDPOINT__ - Endpoint of our appwrite project
   - __APPWRITE_PROJECT_ID__ - Project id of our appwrite project
  
  Configure the cron job to run after a certain period of time that isn't likely to violate the twitter API limits. For Scett I have set this to every five minutes, thus the threads too can only be scheduled in steps of five minutes throughout the day.

![Scett Functions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/52g58tiqr5ni5xwu7nuw.png)

### Front End
Scett's Front-end is made in Vue3, using the src script sugar.
Clone it from github:
```sh 
git clone https://github.com/xinnks/scett.git
```
cd into it and run `npm install` on your terminal.



### Submission Category:
Web2 Wizards


### Link to Code
Here is Scett on github.
{% embed https://github.com/xinnks/scett %}


### Additional Resources / Info

Scett is powered by the following open source projects.
- [Appwrite](https://github.com/appwrite/appwrite)
- [Vue](https://github.com/vuejs/vue)
- [vuex](https://github.com/vuejs/vuex)
- [vue-router](https://github.com/vuejs/router)
- [node-twitter-api-v2](https://github.com/PLhery/node-twitter-api-v2)
- [Tailwindcss](https://github.com/tailwindlabs/tailwindcss)


&nbsp;

### Screenshots/demo videos

![Home Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d8qhaeanwwbq1cg1aqzd.png)

![Login Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8l92bdis9b5dcs886k6t.png)

![Dashboard Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6o6gjio500np0e8bgjzp.png)

![Viewing Tweets](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iu3bb5e43lfg01jh00wi.png)