In this tutorial, we'll create a Moonlit app that automates the process of injecting internal links into a blog post. This app will demonstrate the power of combining multiple functions to create a sophisticated content workflow.

App URL

App Overview

Our app will consist of three main steps:

  1. Scrape the website's sitemap
  2. Retrieve the most relevant pages for our target post
  3. Use an AI model to inject internal links into the post

Step 1: Setting Up Inputs

We'll start by adding two input nodes:

  • Sitemap URL: The URL of your website's sitemap
  • Target Blog Post: The content of the post you want to enhance with internal links

Step 2: Extracting Sitemap URLs

Next, we'll add the "Extract Sitemap URLs" function:

  • Configure it to use the sitemap URL input
  • Increase the limit to 300 URLs (default is 100)
  • This function returns a table with URL, title, and description columns

Step 3: Semantic Retrieval

Add the "Semantic Retrieval" function to narrow down the most relevant pages:

  • Set the table to the result from Step 1
  • Use the target blog post content as the query
  • Set the Number of Rows to 30

This step helps prevent AI hallucination by focusing on the most relevant internal links.

Step 4: AI-Powered Link Injection

Finally, add the AI Chat model:

  • Provide it with the shortlisted blog posts and target post content
  • Instruct it to add internal links naturally throughout the post
  • Allow for minor text adjustments to improve link placement

Testing the App

To test the app:

  1. Use a sample sitemap URL (e.g., Semrush blog)
  2. Input a target blog post from the same site
  3. Run the app and compare the original and updated versions

Key Takeaways

  • Moonlit apps can combine multiple functions for complex workflows
  • Semantic retrieval helps focus on relevant content and reduce AI hallucination
  • AI models can be instructed to make contextual decisions when modifying content

By following this guide, you've created an app that can significantly streamline your content optimization process. In the next lesson, we'll explore how to combine multiple apps into a comprehensive content pipeline.