XMTP 🛠Building a Bot Army
ETHGlobal·Mon, Oct 9, 2023, 12:00 AM
Join us for workshop titled, "Building a Bot Army with XMTP". Some of the most skilled web3 developers, designers and product builders from all around the globe came together for a weekend-long hackathon at ETHGlobal New York 2023. ----------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com
Transcript
[Music] hey everybody my name's Nick I'm a developer from xmt and today I'm going to be showing you all how to build your Bot army with xmt so first let's back up uh what is XMP it is the secure messaging Network for web 3 and so what problems is XMP designed to solve in the web 3 world there are some problems that anyone who's built to DAP has probably experienced it's hard to reach your users if all you have is a zerox address if you're a Creator in web 3 you can't interact with your audience maybe you sold 10,000 nfts but how do you actually talk to them how do you get feedback from them and users can reach each other we see decentralized marketplaces uh but there's no chat button there's no way to communicate between different participants in this onchain economy xmtv is is also designed to solve some of web 2's biggest problems in web 2 messaging is siloed inside each app I can't send a WhatsApp message to Snapchat or a Twitter message to Facebook that's because you don't own your messages the apps do and they want to control them very tightly so xmt was created with composability and interoperability in mind as you can see here these are three different apps on xmt and you can have one inbox shared between them you can send a message from coinbase wallet to lener you can use Converse to see the exact same inbox as your coinbase wallet and that's a really powerful unlock for developers means anyone getting started can have access to the inbox of their user even if they've been using coinbase wallet for the last year you know if you have a better app it's really easy for people to switch over to yours so if you want to say hi you can scan one of these two QR codes one's for coinbase wallet and one is for an app called Converse and just shoot me a message and I can pull it up on the screen here hold on let me go back all right somebody's got to send me a message oh when there we go so this is our example app XMP is not in the app business but we have a nice little web example at xmt p. chat just so Debs have something to play with so want to show you a few of the apps built on top of xmt this is probably the biggest bot Army on the network right now uh coinbase launch onchain summer in August um and built a massive list of users uh on the XMP Network they were getting drops every day for new nfts to Mint uh and you could actually mint an NF in like two Taps from getting a message so became really popular orb is one of the most popular apps in the lens ecosystem all lens apps use x SMTP as the default messaging layer and so if you have orb you have XMP on your phone even if you don't know it at this event we're uh launching a new bot that you can actually order toothpaste deodorant Red Bull anywhere in this venue on xmt you can come by our booth scan the QR code and then order anything day or night and we will come deliver to you this is powered by ens and an app called chainet that built the bot framework for it very cool highly recommend you try and pretty much everything on the menu is z and you know biggest launch of this summer we launched messaging inside coinbase wallet so any one who has access to coinbase wallet can actually have an inbox and send messages inside coinbase wallet Converse is an app based out of France they have a really cool feature where they can do matchmaking based on your onchain interactions so they'll look at your forecaster or your uh lens social graph and tell you who you should be chatting with very cool highly recommend you try it out and there's actually you know hundreds more apps built on top of XMP including a whole lot lot that came out of hackathons just like this one the reason we have so many apps is because this is designed to be a simple protocol for developers to pick up send and receive messages you see a bit of code here uh this is really all you need to do a full roundt trip on the XMP network uh create a random Wallet create a client start a new conversation with some address read the messages send a message and you can listen on a stream all messages and that's kind of all you need to build any sort of a messaging app but what we found is that when you're building a bot you have more demanding needs and so we wanted to build a framework to allow any developer to build a really high quality bot Bots are an essential part of any sort of messaging ecosystem daps use them to keep in touch with users they can connect from your wallet to all kinds of services like chat GP uh and allow you to build really complex workflows without Smart contracts or needing a lot of you know complicated onchain code you just spin up a bot write JavaScript and have a very sophisticated application and so that's what we're going to do today yeah this botkit Pro was released last week but I think you're the first people to ever look at it since we kind of soft launched it uh but it's designed to just make building highquality bot dead simp Le and follows all the best practices that we've been educating developers on for building a good Bond so I have a repit if anyone has their laptop and wants to follow along at home you certainly can and then I'm going to run you through what it looks like to build this Bond give everyone a second to take down the address I'll pull up the code last all and all riser so this is uh the simplest bot you build with xmt this is all you need as a Handler for the bot it's just going to reply GM anytime a message comes in we have uh this run function that lets you pass in that little bot here and connect to a database to store the messages and allow you to resume if your buckets interrupted it can go back and fill in missing messages which is is a common paino for people who are trying to run actual bots in production you don't want to miss anything gives people a bad user experience so we built this to smartly just pick up where it left off fill in any missing messages and send replies so we can actually run this bot in the terminal right here all right and this has printed a QR code of how to message this bot if you want the very exciting experience of getting a GM back from this code uh you can scan the QR code right now shoot it a message in Converse and hopefully this will work oh I see messages coming in so sending a GM that's you know good and fun but a lot of people want to build much more sophisticated things inside of their bonds and so we're going to run through a more powerful example using some of the advanced features of xmt xmt has a notion of content types and so in addition to text messages you can also send images uh videos you can send reactions and replies so we're going to use the remote attachment codec which lets you upload media and a number of XMP apps already have built-in support for their mode attachments and we're going to use that to do a gif Search bot and so let's make sure this thing arounds so let me show you what the code for our GIF search looks like this is the bot Handler so this is all the code that will run every time a message comes in and so it comes with the XMP message that was delivered message content property is going to be the text so someone's going to ask for a you know office GIF maybe so search queries the office I wrote a little wrapper for the tenor API and so we're just going to search tenor which is uh you know free GIF search engine and get back the URL the GIF uh since I don't work for tener we're not going to go too deep into that once you have that we got to create an attachment attachments aren't actually stored on the XMD Network we're kind of designed for small lightweight messages and you know movie files or multi megabyte gifs not a great fit and so what we do is we actually upload this to ipfs and then we have a pointer to the encrypted file on ipfs so the file is public but no one can read it except for the recipient of the message that has the decryption keys so I can run through the code here for creating an attachment so we're actually going to download the file so we have the bytes um we're going to create this encrypted attachment where we have some very nice helpers built into the codec this is all a package called xmt content type remote attachment which you can use to send files movies whatever you want on the xmt network of unlimited size since you're going to store it somewhere else and you just have to take care of um you know having enough credits in your ipfs token so you create this attachment and then we can send it and so when you send something with a custom content type you just have to specify what content type it is that also comes from the xmt content type remote attachment repo and you pass in that attachment and it'll send that reply so we're going to restart this bot now with the GIF and turn off the GM bot all right and we got a new QR code this bot's going to be on a totally different address let's see if it can actually send you a gif if you put in any anything you want it's going to search tener which is the equivalent of Jiffy get you back a matching JF so yeah all right so we have five minutes left on this talk I W to you know open things up for Q&A what can I answer for you about xmt oh shoot not currently they have their own kind of custom oh uh the question is does farcaster use xmt and the answer is no they have their own kind of home brewed uh DM solution you know if you think they should use xmt love it if people uh you know get vocal in in their face about we certainly have a lot of chats with the farter team I think everyone would love to move to single interoperable standard I think they'd like to see that there's support from their users as well yes my gu only accessible that's right yes so the way that it works is we just generate a random encryption key on the sender side and we send that as a message um along with the URL of the encrypted content and so both sides who have access to that message have all you need to decrypt the content and so you can see it as well yes oh uh what about heavy files so in the case of remote attachments storage is handled off of our Network and so you can make it as heavy as you want obviously it's going to be a strain on the recipient if you have you know a 5 GB file we tell app developers to make it an explicit action to download the content so that you can't just like accidentally download a 4 gigabyte movie on your phone if someone sends it to you and that's kind of a good ux practice but us as a protocol we don't specify that it's just what we tell developers to do and if you look at most apps in the ecosystem they will uh try and do that we also do include the size of the file and so you could build an app that would you know download something if it's under 5 megabytes and then ask you you to download it if it's over 5 megabytes something like that that's all possible all right if there's no other questions uh we will be at the booth right uh next to Bas and uh the EF and ens and you can come by anytime and ping me for questions uh I think this botkit Pro is going to be a fun tool to build hackathon projects with so I hope to see a lot of people trying oh uh the question is is there an environment we recommend I am you know the developer of this bit Pro and it's very new it works definitely on Linux and Mac OS Windows your mileage may vary but I'm happy to uh help you work through whatever issues there are it's a simple node.js app it runs in Docker too so you could definitely make it work inside a Docker container all right thank you everyone
Automatic transcript — names and jargon may be misspelled.