Farcaster mini apps are web-based applications that integrate with the Farcaster protocol by implementing a compose endpoint that returns JSON metadata (including title, description, and URL) and a data endpoint that handles frame messages from users, enabling developers to create interactive experiences like grammar correction tools, translation services, or any web application that can be embedded within the Farcaster interface.
Build Farcaster Composer Actions: A Technical Code Walkthrough
Added:farcaster mini apps or compos direction as they're called today how can we actually quick start how can we build them how do we actually go and build one well first of all on the tutorial page on dvision on the web page Link in the description as well you can easily see this is what we're building right we want to build this little mini up thing this is the developer preview on web this also just how it's going to look in Mobile because we have to make it responsive that's our job as the developer first quick start there is a git template like a g GitHub temp template that you can use we'll just use it we're going to see the into the directory like go in there install the dependency right away just from clicking copy Opening Our terminal pasting it in and then we'll just wait for it to clone once it is cloned we're already in there we already have the dependencies installed we can just open vs code with that folder and we're here right so now we just follow along the tutorial and then we'll be good so the actual top itself also has I just said all their codes you can just look in there for what you need it also has a literal description on how you can do your testing and what you need to change as it's in here right so you can just also go to the GitHub do it easily don't need this video if you already know otherwise I'll walk you through now so let's just make this a little smaller first of all you need to understand that we're going to be now shipping a custom composer action right now already if we were to deploy just how this is today and just straight out of the repo we would already see this little hello main test right so but there's no local debugger that I'm aware of you could simply go npm runev you get Local Host 3000 Local Host 3,000 and right away here's your web page right and and this is also the same thing that is going to be seen in the client because we're just building web page right you have to understand this is just a web page like there there's no no complex anything it's a web page the only thing that is faras specific is that in our source directory we will have an API page that I just called compose but you can do whatever you want with it that is just going to return this URL and you may not want it to be Local Host you may want this to be your extra domain like D do Vision or something else um you want to name it you want to choose an icon which the docs tell you what a valid icon is like an error checkbox anything and you want to give it a description and here you can also promote your stuff or just put the same web page in again and this is what is going to show in wobcast when they show you a preview like this is the title the description all that they get that from this post metadata route and from the get uh from the post story from the post you'll get a frame message and you'll just return the page where they go to on a get request you're getting them the information so how it works if if we look at it a little more in detail so we go to compos retions mini apps BL it's also all in the docs there's something on what you can actually do with them but the general gist is just okay here is our foraster client webcast for example and that is going to say hey I want to use use this composer Direction this mini app okay here is our response and then they're going to say yay this is cool this the description whatever right and they're going say hey please give us that web page that you're talking about like the user actually wants to do this and then it's going to be shown right because you're returning that and this is the two parts of the code that do it for you like all you would have to do to turn an existing web page into a mini app is just that that's all add a rout that returns this and this is Json by the way right so like you can use any language any framework as long as you return this little piece of Json and you're good to go if you want to see how that looks like documentation has samples for the down below you can also copy it there or from the GitHub right so we already know how to set that up and we'll change that to The Domain later we're not going to host it we'll just walk through the building and now that we have that and we also know that we have an image that is square for the icon and all of it we can actually go and look at how warcast is going to know what we're actually composing so the way that it works is that while I'm on wobcast and we can just quickly do this if I actually post a cast and I go here and I'm searching for an action say like snake then what I can do is I can actually share this right so if I click share then my web page that I've built here is going to tell wobcast to prefill all of this text and there's my framing so I could do free marketing or get the user to post whatever or if I'm actually a helpful composer action for the user typing something I could build like a grammar correction a translation so I'm typing in German but then I hit the translate to English and it's just going to autofill that um so that would work just from repping it and then you can have people post right so to get that we have to pass the message onto the actual webcast page which is by doing this window. parent post the message get the message up to wobcast so they know what you're doing it's going to be type of create cast why is there a type well because they want to be flexible right in the future this can change and then they don't have to change anything besides saying hey there's a new type that you can return here and then we have obviously the text and the embeds uh that we want to do like the text is the actual text and the embeds could be images whatever right just put in a euro out there and then this is this is how you return and this is not in the actual compose this is in the index so in our our source pages in our index our main page our main just web app has that well what you could also do is you could check if you're embedded in an i frame in webcast and then you can change your button right whereas you may want to just use contents or something else like Twitter or just send the user somewhere else or do something else if they click that button you can check if they are within wobcast and then you could do that I'm not going to go into all of it so as we've now seen we have a button we can create a button for user to exit it and prefill the text so right now in this template this is our whole thing that we have here as well if we change it from DTE is the best to have hello world then this text will not be detect as the best it will actually be hello world right so this little thing if we know press that on warcast we would now get the text filled with hello world because that's what we do in our post message and then from there if we want to actually get all of this like chocolate selection and ice cream selection and all of it we can just use regular good old whatever programming you want to do for the web pages in this case this an xjs sample so we could just add all of that code in which I actually put all of this in here so you can just go copy that over and you should technically not have it because I didn't include all of it right yeah I'm a sucker so if we just look at it again previous code remains unchanged ha I'm a sucker I'm like the the AI Bots that don't give you anything okay our home function home and we go down even before the return okay so we just add that to our home we need the use State import yes okay nice and then we actually have to get our button is this main do we have the main yes we [Music] do so the only thing we're adding now is the actual form and selector to do all of this so we what do we want do we want still want the logo okay let's just replace that text right here let's just replace that text right here okay cool so now what we have done is this already changes and we actually have our text here this white we actually want to have a text also be in Black so we can just we should just be able to go is there a text text color text black i' say okay and now it's all black right something I should actually change on the web page but as you can see we just use Tailwind we just do web web programming frontend stuff good old and now you can just select and since we've selected more than three it doesn't work and now we can select other ones and if we hit share then well we don't see anything why because we're on the web page we're not actually on webcast so if we now change this on click and now we're saying console. log um hello world then we can just quickly open that console and we're now seeing hello world right like this is good old web programming this is not different than anything you have seen before or already know so now the only thing you need to do deploy this somewhere go into your compose change that URL to where to deployed or use something like veral process. m. Verso URL or uh Local Host right SL Local Host 30,000 and that way is because our environment variable isn't set we would actually get the Local Host back for our testing and if we deploy to versal we would actually get the versal thing and then we can change this to not it's not Creer poll frame it is actually share your favorite favorite ice cream right uh this is what we do and this is our ice cream pole and this is all you would do and then we can also look at the different kinds of icons that we have okay so this is maybe what which one do we pick Let's just pick an a heart because we want to actually get our favorite ice cream and where were we ADV code so we can now get that in here now it's a heart right and and that's all of of the ways that we can change this and adopt this and we're already done right like right now here it's still the hello world text so in our index we can just go back walk through the tutorial more and just see okay we actually want to change our cast text and we actually want to build this cast text and we can also use a handle share function so let's just do that and we want to potentially disable it and like we can do all of this fancy stuff I urge you to just read through that tutorial to deploy there's also a a tutorial to go into the debugger and we could also build snake um which which I haven't written up fully but you can just go program your snake game in here as we did with the form and you're done right that's all that's all I've actually done so this is how you build the composer action this is how you actually get to this part the deployment it's is highly up to you how you want to deploy this and then what you do in the actual frame debugger which this is one that I actually should show you is you will go my https My url.com sl and then you have the compose endpoint right so this is your API endpoint which is the compose this is where you want you want it to hit where you want it to go and there you handle the post and you get handle the get for the metadata and that's all then you have to put some text in here because then otherwise the it's not going to send any text and then you can just get that text right how would you get that text that is sent to you here in that data endpoint we're already logging it so you'll see it while you're testing and while you have it deployed but here in on that data endpoint because you're actually just getting a frame message you can go to the frames specification and in the flame specification we can just search for message and then it's going to have the message and in that frame message which is actually uh documented further below I think yes this is the the general type that you that you can expect and that you're going to get you have this unrusted data and all of it so that is basically what you're getting and and what you can expect so you also get the FID you get the temp stamp you could even lock a user in right right like right here if you can verify the cross set messages like the message B is a signature and it matches with that FID then you know already know okay this is this user I can return um a session cookie as well and already know that the user is logged in and do some more magic if you actually want to do that magic I would actually urge you to go on the dtec web page again and under frames there is an authentication signin uh authentication tutorial and there we already do that it's also a video version on this YouTube channel and then we can already know how to handle the login how to verify all of this and actually go and do it right and then we're we're building the sign in with FAS frame message uh and all of it right there and we're discussing security of it whatever and this is in the response so for more details look there but this is just a general rather quick start on how you can get your composer reaction on I know this is not a full code along because you actually have to do the coding yourself because otherwise you sadly won't learn and on this build more cool so
Up Next

Lauren Elkin Discusses Flâneuse: Women Walk the City in Paris
@NigelBeale
2.3K views•2018-02-03

Walking in the City: Urban Rituals and the Flâneur in Contemporary India
@PSBTIndia
1.9K views•2016-08-02

FastAPI vs Flask vs Django: Choosing the Right Python Web Framework
@TechWithTim
302.5K views•2024-05-26

Game of Thrones Opening Credits: A Cinematic Analysis
@gameofthrones
46.3M views•2011-04-18
Related Study Plans & Knowledge Roadmaps
Structured learning paths in General & Interdisciplinary Studies















