Confbrew: A Getting Started Tutorial with Markprompt and Contenda
Confbrew: Markprompt & Contenda Tutorial
This tutorial was generated from our video tutorial. If you’d prefer to watch, head over there!
Uploading a YouTube playlist using Contenda APIs
In this tutorial, you’ll learn how to convert a YouTube playlist into a Q&A bot. We’ll use the Contentful Fast Forward 2022 Conference playlist as an example.
- Open this Autocode Template
- Hit
Run
onmain.js
This file will grab the playlist ID from the YouTube URL and call the Google YouTube API endpoint to get all the video IDs. Then it will call the Contenda API, which takes the video IDs and generates tutorials in Markdown format. These tutorials can later be converted into a Q&A using Markprompt.
const lib = require('lib')({ token: process.env.STDLIB });
const { google } = require('googleapis');
const apiKey = process.env.apiKey;
const playlistUrl = 'https://www.youtube.com/watch?v=_tLJRAl';
// Extract the playlist ID from the URL
const playlistId = playlistUrl.split('list=')[1];
// Function to get video IDs from a playlist
async function getPlaylistVideoIds(playlistId) {
const youtube = google.youtube({
version: 'v3',
auth: apiKey
});
const response = await youtube.playlistItems.list({
key: apiKey,
part: 'snippet',
maxResults: 50,
playlistId
});
const videoIds = response.data.items.map(
(item) => item.snippet.resourceId.videoId
);
console.log(videoIds);
return videoIds
}
Afterwards:
- Wait for Contenda to process the jobs (depending on the playlist length and video size, this can take a few hours)
- In the
receive_jobs.js
logs, observe the jobs being queued up and processed.
Integrating Contenda and Markprompt
When a job is successful, the Contenda endpoint sends back the status as “success” along with the job ID. We store this job ID, call the Contenda API to get the blog ID, and then create a paired array. Our receive_jobs.js
file now created job IDs paired with blog IDs in local key-value storage.
Next, we need to modify our markprompt.js
file. First, change the Markprompt key to match the project you’re using. Sign up for Markprompt, create a project, and generate a token in the settings. After adding the Markprompt key, save the environmental variable.
The goal is to create key-value pairs where the keys are the blog IDs, and the values are JSON objects containing the markdown from the content. Contenda provides a “retrieve as markdown” endpoint that returns markdown for a given blog ID. Simply stringify the returned object and add it to the files
array.
Markprompt can then accept this JSON array and train on it. Run the code and verify if you receive a 200 status response. Go back to Markprompt and check the “Data” tab, where you should see all of your videos as blog IDs.
You did it!
In order to search through video content effectively, you are now all set up to use a combination of Contenda and Markprompt APIs!
With these tools, you can access valuable information that might be locked up within videos, like customer panels, which may not be easily searchable on platforms like YouTube.
You can join our Discord for help or feedback. We’d love to hear from you.
Happy shipping!