Mar 10

How I Built a Working App in 10 Minutes With Colossyan's API

Matt Bristow
https://colossyan.com/posts/how-i-built-a-working-app-in-10-minutes-with-colossyans-api

Being a self taught coder means a few things. 

Firstly, it means my spine makes it look like my body is asking a perpetually unanswered question. 

Secondly, it means that where classically trained devs may take a measured and analytical approach to new technologies, I tend to smash at it with a metaphorical hammer until I get a working prototype.

In my entire time smashing things with hammers, I’ve never dealt with something that responds as well to the hammer smash (read: it’s easy and intuitive) as the Colossyan video API.

We recently built an AI fortune teller for a Valentines campaign here at Colossyan, and I was lucky enough to be asked to build the thing, which meant getting my first taste of using the Colossyan API in production.

As it was such a fun and rewarding experience, I decided to write a blog on how I went about it, to hopefully inspire and guide people as untalented as me in how to create content at scale with Colossyan.

Onboarding video created with Colossyan's API

Making the video

The key to making really high quality scalable videos, is making one really great video and then scaling it. Reading that back it sounds very stupid, but I’m going to keep rolling with it and hope that Maggie, our infinitely talented Content Marketer, doesn’t cut that bit, because it’s actually true.

You can obviously choose from the 200+ prebuilt avatars in Colossyan, but for our campaign, we needed a super specific custom avatar, so we leveraged Colossyan’s Instant Avatar tech to make a brand new avatar of a fortune teller.

Once this was ready, we built the rest of the styling for the video, with {{script}} and {{name}} tags to personalise later.

Then, once you’re absolutely ready, you click the ‘Export to API’ button, which will break your video into a ‘job’ that you can use in your API call to create a specific video.

Code to export video generation job to an API call

Getting your API key

To use the Colossyan API in your workspace, you’ll need to get your API key. To do this, you’ll need to navigate to your workspace settings, and then go into workspace details, where you will be able to generate and copy an API key of your own.

Getting your API key in Colossyan

Calling the API

Now it’s time to code!

I copied over the job object from the above section into my node.js app, created a function called generateJob with parameters for the bits I wanted to personalise (name and copy for the script), calling this function whenever a user submitted a request for a fortune telling to create a personalised job object that represents their video.

Code with personalization parameters

Once generateJob is finished and has returned the custom job object, I use that data to call a function called generateVideo, that uses the https://app.colossyan.com/api/v1/video-generation-jobs endpoint, and append the customized job to the body. If successful, this will return a videoId, which we can then use to check the status of the video and also send the video to our users!

Code to call the generate video function

And that’s it! With just those few lines of code, I am now generating a video in my account that’s completely personalised to the user’s inputs! Smashing things with a hammer for the win!

Checking the progress of your video

It’s not enough to just generate a video (albeit that is very cool in itself). We now need to check when the video is completed so we can send it to our users.

For that, we take the videoId given to us from our generateVideo API call, and make a GET request to the https://app.colossyan.com/api/v1/video-generation-jobs/ with the id appended to the end of the URL. 

Code to check the progress of the video

This will tell you how your video is doing in terms of generation. All you need to do is set an interval to repeatedly check the progress, and when the response status is ‘finished’, your video is ready!

Sending your video

Once the video is finished, we then took the videoId and used it in an email, as we were using the Colossyan videos as embedded iframes, but you can also take that video ID and share it the Colossyan inbuilt share page, by just adding the videoId to the end of https://app.colossyan.com/videos/. Connecting this to Slack or via an email means you can have custom alerts or send the video to your users as soon as it’s ready.

And that’s how a man once described at school as only ‘debatably smarter than a rock’ can create an AI video application in 10 minutes. 

If you want to see how Colossyan’s API might work in your business, book a demo or learn more about how our API works.

Branching Scenarios

Six Principles for Designing Effective Branching Scenarios

Your guide to developing branching scenarios that have real impact.

Matt Bristow
Senior Performance Marketing Manager

Matt is a performance marketer obsessed with spreadsheets, retro technology and getting hopelessly lost in the great outdoors. When not writing and launching paid ads, he'll usually be running, hiking, coding or watching the same four Netflix shows on repeat.

Latest posts