BrandGhost

Designing a Social Media Assistant in C# .NET

This is the first part of a video series where I work with my content editor, Jamal, on building a system to help with automating some of the aspects of social media. For additional context, Jamal is a smart cookie but he has limited programming experience. He's very good at conceptualizing how parts of systems need to work together, so I am confident he'll pick things up super quickly. Let's find out! Check out more Dev Leader content (including full in depth articles with source code example...
View Transcript
hey so thanks for checking out this video where we're going to talk about building a social media assistant and uh before we dive into it if you could do me a favor and like the video and subscribe to the channel if you find that this content is valuable that would be awesome uh and for you know helping the YouTube algorithm if you don't mind leaving a comment below uh and you know if you have questions and other thoughts too I'm happy to answer stuff in the comments as well so it's greatly appreciated so the topic of today is creating a social media assistant and I wanted to give a little bit of context here because this isn't a project that I was kind of planning on diving into I have a bunch of other stuff that I'm trying to program and spend time on but I think this is kind of relevant and ties into some of the stuff going on for me currently so more recently I have been syncing up with a friend actually that I know from from high school so I've actually known him for like over half his life now and his name's Jamal and he's going to be helping me and has been helping me the past week and a bit with some of my social media and to rewind a little bit um I've been sort of creating content about programming and you know engineering leadership for I don't know like 10 years now but I have not done it consistently at all um so in like 2013 I started blogging about stuff and I was getting in the groove of it but I was never consistent and um you know periodically over the last 10 years I would get into a burst where I'm like hey I want to start creating content and then you know I might go right I have like an idea for a blog post or something so I go write it and then it takes all of my energy and I feel like I never want to do it again and video creation has been a little bit easier in that sense but what would happen is I uh maybe have content that I want to have span over a couple videos and I get in you know part one and I'm like I I'm exhausted from it um I don't know maybe it's just how I am or maybe it's some of the other times spending like having to think about editing and posting and putting the you know the meta information on videos it's just it seems like it takes too much of my energy and more recently I have been trying to take some advice from other content creators and other people that I look up to um so a couple of names that you're probably familiar with are one is garyvee I think most people probably have heard of garyvee he talks a lot about posting uh to social media channels basically if you think you're doing it enough you're not doing it enough and basically blast out everywhere you can and another person that I look up to a lot is Alex hermosi who when he talks about being able to become successful he he really you know emphasizes the fact that you have to be focusing on you know this period of time where it's not comfortable not enjoyable you're not really necessarily seeing the results and kind of grinding through it and I think that I have not done a good job of that so um Jamal has uh recently been helping me with my content creation um and he's actually made it like extremely easy for me and that's made it such that I can post things to every social media channel daily and that's really cool and now we're kind of talking about okay now that we have a bit of a Groove going what else can we do how can we optimize things a little bit more and one thing that came to mind was well if we set some goals for posting and analytics and things like that it would be really cool to be able to Trend that and make sure that things are going in the right direction so um one of the platforms that can kind of help you with that is something like HootSuite um and because I don't have enough of a following or I don't have um you know I'm not running ads and making money off of uh my social media posting and stuff like that um for me to go pay for something like HootSuite I'm like it's just not it's just not worth it right now if I had an income from from this uh that might be a different story where I'm like hey it's worthwhile but I am a programmer so um I think I can do some of the things that HootSuite does that um that I would like to take advantage of for some of my social media and when Jamal and I were talking one of the things that we were looking at doing to start with was basically um almost like an accountability tracker for being able to post to social media so am I doing it at the right Cadence that kind of thing and if we're setting goals so say I'm just kind of making up some of the numbers because I actually haven't gone through the exercise yet if I wanted to reach I don't know I want to reach 200 subscribers on YouTube by the end of February 2023. um I haven't actually checked I probably don't think that's realistic but if I wanted to do that am I actually posting enough content or are the metrics going in the right direction and we wanted to start by saying well if we can check on the social media accounts the number of posts then I can on a regular Cadence go we're not on the right trajectory I need to be posting more content so pretty simple concept and um when I was talking with Jamal I was saying this is actually something that I think I can work with you on because Jamal is someone that wants to become better at programming I said I can work with you on this and we can actually go build it together and we could record it and I could um you know we can have some content about building a system so today I told Jamal I was going to record some content um and this is actually some unplanned content I'm still going to make another video today um but I wanted to go through this as a first step to kind of introduce the concept and then jump into kind of what I imagine is a high level system design and the the part that I also didn't tell Jamal is that while we talked about initially building something like a post counter tracker uh to see if I'm on the right Cadence um I actually want to eventually extend this I think to automate a little bit more of my work which is right now when I post a social media I'm not like I said I'm not using anything like HootSuite or other platforms to let you kind of publish out to multiple channels at once I can also code that um and I can show Jamal how we can build that together and actually have a system that will let us do a little bit more than just post counting tracking and follower tracking we can actually build something that will let us take a concept for a post and then publish it out to different sources so I wanted to jump over to paint.net so with Jamal's help this will be a nice fluid transition which is really cool and you probably haven't experienced that on my channel yet and we'll jump into paint.net now what I'm going to do is describe some of the system that I'm thinking about building and as I've mentioned I haven't actually gone through this with Jamal yet so I think um in a follow-up to this content we'll have another uh video where I'm discussing some of this with Jamal um and kind of going through what the different pieces are supposed to mean so for a system like a social media assistant the first thing that comes to mind for me is that we're going to have a bunch of web apis to be able to access the different social media platforms and if we're starting with something that's just like being able to pull information from a social media profile like the number of followers or the number of posts there's probably social media apis depending on the platform that let you access that kind of stuff more easily because sometimes it's public information so when we think about social media accounts and different platforms if you're familiar with them you might know that if you go on to a particular site and I'm I'm kind of generalizing this because I actually don't know the specifics of each of them but you could go on to a specific site and you don't actually have to be logged in but you could see um you know a celebrity and you can see how many followers they have or something you can kind of scroll through their content um so some of that's just public information and API access to that might be a little bit easier um and there's going to be other platforms and other pieces of information that are private and you will need uh you know a different authentication scheme or perhaps different API paths to be able to access that so I'm just calling this out because it's not necessarily more complicated it's just that depending on how those social media apis are built it might look a little bit different so the first part is going to be that there's going to be some API access as I mentioned and the second part that comes to mind for me personally is that especially when we go into things like posting to different platforms I'm really thinking that we're going to be able to take advantage of something like a plug-in system here so I think depending on your level of experience programming and designing systems like this I would recommend of course you kind of you kind of start with one platform that you're familiar with so for example it might be like um uh I'm gonna pick tick tock right tick tock's super popular right now so being able to look at the tick tock API checking out um you know if you give it your profile name pulling back the the number of followers or the number of posts and stuff like that you might start with that and kind of build an end-to-end solution for checking that um in a little tool or something and then you go okay great now I want to use um you know Instagram is the next platform and what might happen if you're not you know experienced kind of Designing a more extensible systems is that you find yourself kind of putting a bunch of if-else statements like if Tick Tock then go do the tick tock code else if Instagram go to the Instagram code and a lot of the time that can lead to kind of messy code you know if you want to refactor some of the code you've written you might find it's really chaotic to try and manage and it's hard to extend uh to other social media platforms over time so with a plug-in system that I'm kind of thinking through the idea would be that we can kind of abstract some of the concepts away and then we can drop in New plugins for different social media platforms as we go so that's something that I want to keep in mind as we go through this but I'm really terrible at drawing so this might be kind of fun to to watch and I apologize if this hurts your eyes as I'm kind of trying to to draw a system like this but what I kind of Envision um and to start like I don't know if we need um a GUI quite yet right so if we're going to start with some social media analytics or something just to pull back a number of posts and followers uh what I kind of Envision is that we will have a bit of a shell program so I'm just going to start by drawing something like a box here to just kind of represent the shell I'm probably going to see if I can just put text instead of um trying to write with my mouse because that's where it's really going to hurt your eyes and I'm just going to write entry as well because that's going to be the entry point to our program and the shell program itself um if when we're talking about plug-in based systems the reason I'm calling it like a shell is because a lot of the other content that we're going to be building to say you know actually go do the work to pull stats from Tick Tock and stuff like that that's going to be located inside of the plug-in and you will find that with a plugin based system you can push a lot of the logic out to the plugins and you end up having a program that's pretty light kind of wrapping your plug-in logic and obviously this depends on the style of application You're Building so for this one um you know we might start with a shell program that's a console app because I think to start we can probably just get away with writing you know things like uh like basically launching the program and having it come back to us with um stats like just print it out to the console nothing fancy um I'll talk about maybe some extensions of this later but a shell program that's an entry point and I'm jumping the gun a little bit here because I'm suspecting that at some point we're going to want a UI and not actually like a console for doing this so I'm jumping the gun to say that I want to have something like I'm going to call it an engine here [Music] um and I've told Jamal this but the the hardest thing in programming is coming up with names for things so I'm going to call this the engine um core I'm just going to write Core Business logic as well so the reason I'm doing this separation out initially is that I I Envision a fast follow once we want to get into actually doing like posting of content typing all of your Social I think typing your social media posts into a console and then trying to have like you know attach a video to it and stuff that's going to feel kinda crappy in a console application it's probably doable probably gonna feel crappy um you want to keep this shell program super lightweight and push um logic into this guy here okay um because if later we want to actually build a user interface on top of this right I'm just going to draw this box here um we're not going to do this part yet but this is where your graphical user interface would be what we'd be able to do is basically connect this down to here and we actually could get rid of this if we didn't want it anymore but the point is that if this part was super lightweight like I wrote then what's really cool is you didn't waste a lot of time coding it because a lot of your logic was pushed to here already okay so hopefully that makes a little bit of sense and when I go through this with Jamal too I'm assuming I'm assuming he's going to have a lot of questions and we can spend more time going into the details of this kind of thing so okay we're not going to have a GUI right away um so I'm just gonna say you know no GUI for now because we're not focused on it and what our engine is going to do to start again I'm kind of thinking through this a little bit for the first time is that um I'm thinking we'll launch the shell program it's not really going to take any parameters or anything like that we'll probably have to store some credentials and stuff like that um I'll have to think about that because if we go to check this in anywhere or share it that's going to be interesting so we'll probably want to file to load credentials from so let me let me draw that somewhere I didn't think this through for where I want to put this um so this is going to be a file and it's going to have API keys so what we'll be able to do is basically pull this kind of stuff in right so we'll be able to pull it in and it's probably not going to have to happen at our shell program level but we'll be able to pass it into the engine as one of the dependencies that goes into this now the shell program will be lightweight it's going to basically call the engine um got a fluffy friend to join us here um and then the engine itself is probably not going to have like many different commands or anything to start it's really going to be one thing that's kind of like get social media stats like very very straightforward because we're not building the posting part yet so let me get rid of this x that I drew because I don't think that's needed anymore um oh no one sec there we go uh my Arrow's a little bit destroyed there but um that's all good so um we'll have something like a method that's get social media stats and it might be something like I don't know I haven't again I haven't totally thought through this but um probably not just a dictionary of like the social media platform and then like um you know like a number after that's followers or something we probably want to have a little bit more of a rich structure there but I think the concept of a dictionary if you're thinking about that um uh to start with I think it will be something like that so what we'll want to do is have this uh method that's like get social media stats um I should have put like parentheses or something to say indicate it's like a method but where it's going to get really interesting is where we get into this plug-in system so when we have a plug-in system like I'm not going to want to put um say like The Tick Tock code because I talked about Tick Tock as one of the platforms um what we're not going to do is say okay get social media stats and then like do uh do Tick Tock stats and then do do Instagram stats do we're not going to do this and the reason we're not going to do this is because um well I have some experience Building Systems that are kind of like this and not necessarily for social media but when you want to extend systems and have like literally have extensibility as a core Concept in a system one of the things that I do not recommend you do is design it such that you have to go um I don't know the best way to phrase this I've heard it called like you know breaking open a class we're talking about like classes with respect to programming right um so if we have to go um edit this engine specifically just to go add another um social media platform that could be considered like a code smell or a design smell from an extensibility perspective instead and I I know we'll be able to do this so I have some confidence here but instead of having to edit this engine just to support you know say Twitter is the next thing that we want to support I don't want to have to go okay like let me go add one more thing right into this engine generally from an extensibility perspective you don't want to have to do this um and one of the reasons why just for a little bit more context there's lots of you know videos and information about this kind of thing on the internet but one of the reasons why this kind of thing is uh potentially you know like frowned upon I guess uh when you you're thinking about extensibility is that if you were thinking about how this is all tested right if we have to go edit the engine to go add more functionality from the outside looking in if we treat it as a black box or we don't know what's going on it's opaque to us we don't actually know what things might have broken from the engine perspective right so if it's opaque to us we don't know if I could tell you though hey look I added Twitter functionality and I didn't have to touch any of the engine code then at least from a testing perspective you shouldn't have to go touch anything in the engine to go exercise right I didn't touch it how could I have possibly broken it that's not to say that I might not have broken the overall end-to-end functionality by adding a new plug-in but at least specifically the engine is not something that I would have broken so hopefully that makes sense we could do more concrete examples of that later from a testing perspective but that's the idea for why I do not recommend putting the things right into the engine instead we'll take the same train of thought that we're going to have the engine itself be kind of like a shell so really what the engine is going to do is it's going to do something like a for each Loop right so this is going to be pseudocode oops pseudo code and what we're going to want to do is um Loop through plugins and then for each of the plugins I don't know a good way to illustrate this so I apologize Loop through the plugins then what we're going to want to do is fetch stats and to do that we probably want to like do some auth right that's why we wanted to pull these API keys in so we'll have to do some auth and then once we fetch the stats the actual engine itself is going to aggregate them and then once we have aggregated stats in memory will need to make a decision about how we want to actually output that so the first thing that comes to mind for me is that if we go back to my original point about starting with a console app and the potentially looking at a GUI like a graphical user interface what I probably do not want to do and again we're just getting started so there's not really a wrong way here but what we probably don't want to do is have the engine just writing this stuff out to the console um and I say that because well if I know that I plan on having a GUI down the road I'm already expecting that if I have the engine writing to the console all that information that comes out I'm gonna have to change that if I want to show it in the GUI later right so I might say that if we go back up here to the Shell program this will do whatever initialization we need uh which might include what I'm going to show Jamal dependency injections so we'll look at Auto fact and things like that I think that's going to be really cool um so dependency injection Di we're going to do that might be it so initialization I think it's probably just like Auto fact for that part then what we'll want to do is actually call um we'll do like engine get social media stats and then we're going to do the printing to the console here now sure I said keep this super lightweight so you're like well Nick why are you going to add this stuff in here and the reason I'm going to add it into the shell program that's you know something extra that maybe we could pull out um I'm gonna put it here because it doesn't get used anywhere else and what I mean by that is if we go to replace the shell program with the graphical user interface well the graphical user interface is never going to need to print to the console and if I put that console printing into the engine it's only ever going to get used by the shell program like that's the only spot that's going to need console printing so I might as well just pull it back out to the console so that's a super high level and really what's going to happen is that we'll we'll have plugins that kind of look like these these horizontals here and this is where we could do we'll start with one right we'll have like tick tock um and then we'll be able to do like an Instagram and so on and so forth and if you were to look inside of each of these where's my brush tool um so inside if we were to go blow this part out that's not what I want to draw at all um you know what what does that look like inside of each one of these this is where let me get my my text tool back out again this is where the algorithm will kind of look like do API um off so I know I wrote that back out here uh all three three API um right here inside the loop is the plug-in my apologies Okay so inside this Loop area the two lines I have highlighted here that's what's going to happen in each plugin and the reason we want to pull it and have it separate for each plugin is this because this is where the most variation is going to happen it's very likely that for each plug-in we need to do we probably need to do some type of API Authentication but I just want to mention that not always and by having it in plug-in form we actually have some luxury so I'll give you a quick example and this um I'm not basing this on the reality of each social media platform because I said earlier I don't have enough familiarity with each of them to know but say for example Twitter I might be able to go get my post count and follower count from Twitter without any um any any API key I might be able to actually just basically make a web request to um to Twitter's website and and scrape it if I wanted to I don't usually recommend going the scraping route um especially because there's probably apis for this stuff but the point is if you break things out into plugins each of your individual implementations you can make decisions about what you want to do so we would do for like how we're probably going to approach it is do API authentication um and then fetch and when we talk about fetching the other thing we probably want to do is once we have that data we want to massage it into a common format and this is actually when you go down the road of plug-in systems or plug-in based systems this is one of the sort of the more common things that comes up and sometimes where people will say oh you're just making more work so when you have a plug-in based system and you want to abstract things a lot of the time what ends up happening is that you want to keep um like domain boundaries so this is maybe a little bit more advanced from like a system design perspective depending on on your level but um we want to have flexibility inside of our plugins to kind of get the data we need to get the way we want to get it that's why we want to break them out into plugins but when it comes time to actually this do this part over here which was the aggregation right the engine doesn't want to know the details about how each plugin works that defeats the whole point of having a plug-in so that means that each plugin needs to have a way to talk or respond to the engine in a familiar format and that goes both ways right so the engine needs to tell each plug-in go get your social media stats and that has to look common at the top level across each plugin then inside so let me just kind of illustrate it this way common API for plugin and then I'm going to do like common return type so not the value is not the same from each one but the the type is so the idea is that when you are calling the plug-in from the engine it's the same uh API like it looks the same inside the plug-in you do whatever you want to get the job done and then once you're done you need to return it as a common type that the engine understands because it's going to have to aggregate all of that stuff and it should not have knowledge about the inside of each plugin so back to my point up here about massaging into a common format we need to massage the data we get back from each API because each social media platform they might do this completely differently and that's okay but we just have to massage it into that common return type before we leave this kind of um plug-in method that we're going to implement and then pull it back out that way the engine can aggregate it for us okay so hopefully that makes sense and I wanted to see if there's one other thing it's worth mentioning if you haven't built plug-in-based systems there's a handful of I'm sure there's many ways to go do the actual plug-in loading so let me see if I can get a different color going on here um we know like the way I've drawn this like this is where the plugins are right so these are the individual plugins we know that these are going to be the things that we want to keep adding on like so the next social media platform let's say it's Twitter um we just want to go add another box down here for Twitter right um I wanted to type Twitter so let me get that out um we just want to add to that and you'll notice like literally how I visually drawn it here is that I didn't have to go into the engine and write that right I just added a new one here so again from like a testing perspective if you're thinking about your system your engine I couldn't possibly have broken code in the engine because I never touched it but from an end-to-end perspective sure maybe maybe my Twitter um my Twitter plugin does this like right now your whole thing crashes that kind of thing so I'm not saying I it's impossible to break end to end but it's impossible for me to uh to break this engine specific code because I didn't touch it when we have plugins like this what I just wanted to show is that when we talk about the initialization at the Shell program level we will probably talk about dependency injection containers this is where we'll probably do the plug-in loading and feed that into the engine um the concept here is that instead of the engine itself necessarily having to go have a built-in like Discovery thing for plugins when we construct the engine itself initialization time at that point we can pull in the individual plugins so like I said there's a ton of different ways to do this part someone may want a system that is while it's running already at runtime they can dynamically add plugins so the way that I describe this that absolutely would not work it's only on Startup and I'm doing that because right now I don't foresee this right now necessarily being a a constantly running service and that while it's constantly running I want to drop in New plugins and have it dynamically update I don't think we're going that route if we want to we can talk about how we change that design okay so to recap um again Jamal's been helping me a tremendous amount with some of my social media content and one of the ideas that we were talking about was basically building something to pull social media stats and then this way I can be accountable for trying to change my social media behaviors to drive metrics in the right direction now I also mentioned at the beginning of this that I'm not interested in going to pay for other platforms and stuff and this is also just an opportunity to create more content and actually kind of go through the process of building some cool stuff so uh Jamal and I talked about building something that could pull these stats the the system diagrams that have kind of gone through are my super high level approach for how I would build a plug-in based system to do that and the part that I would like to follow up with after the selfish part is that um I don't just want it to pull stats I would like it to basically be extended so that I can take a video and a caption different metadata and and blast it out to each social media platform we could look at scheduling and other Advanced features and stuff like that but I will see what Jamal's interest is in that uh and if not maybe it's something I'll kind of tackle on the side as a as needed so hopefully that was kind of interesting I think the follow-up conversation with Jamal will be pretty cool because I think he'll have a lot of good questions and and maybe as you're watching this there are questions that you had too and Jamal will have them kind of come up and we can answer them so thanks again for watching if you thought this was interesting please like the video leave a comment below and let me know what you think um and if you like the content on the Channel Please Subscribe it really helps and uh helps me know that you're enjoying what's being put out so thanks again for watching and we'll see you next time

Frequently Asked Questions

What is the main purpose of the social media assistant being built in this video?

The main purpose of the social media assistant we're building is to help track my social media posting habits and analytics. I want to ensure I'm posting consistently and reaching my goals for engagement and followers across different platforms.

Why did you decide to create this social media assistant instead of using existing tools like HootSuite?

I decided to create this social media assistant because I currently don't have enough of a following or income from my social media efforts to justify paying for tools like HootSuite. As a programmer, I believe I can build a solution that meets my needs without incurring additional costs.

How do you plan to extend the functionality of the social media assistant beyond just tracking posts?

I plan to extend the functionality of the social media assistant by eventually automating the posting process across different platforms. This means I want to not only track my posts but also create a system that allows me to publish content to multiple social media channels simultaneously.

These FAQs were generated by AI from the video transcript.
An error has occurred. This application may no longer respond until reloaded. Reload