Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 20, 2025

The Twilio Content API uses JSON payloads and supports various content types that need to be handled differently, but there were no code examples showing developers how to use them. This PR adds comprehensive examples for all major Content API types.

What's Added

10 new example files demonstrating different Content API use cases:

  1. ContentApiText.md - Simple text messages with template variables
  2. ContentApiMedia.md - Rich media content with images/videos
  3. ContentApiQuickReply.md - Interactive quick reply buttons for user choices
  4. ContentApiListPicker.md - List selection with detailed item descriptions
  5. ContentApiCallToAction.md - Action buttons (URL, phone, copy code)
  6. ContentApiCard.md - Rich product cards with media and interactive actions
  7. ContentApiLocation.md - Location sharing with coordinates and addresses
  8. ContentApiCRUD.md - Complete CRUD operations and async examples
  9. ContentApiAdvanced.md - Carousel and catalog content for e-commerce
  10. ContentApiOverview.md - Comprehensive guide with best practices

Key Features Demonstrated

  • Builder Pattern Usage: Shows proper construction of complex content objects
  • JSON Payload Creation: Demonstrates how Content API differs from form-encoded APIs
  • Template Variables: Examples of personalization using {{variable}} syntax
  • Error Handling: Best practices for handling API exceptions
  • Async Operations: Both synchronous and asynchronous operation examples
  • Content Type Variety: Covers all major content types from simple text to rich carousels

Example Usage

// Create interactive quick reply content
var actions = new List<ContentResource.QuickReplyAction>
{
    new ContentResource.QuickReplyAction.Builder()
        .WithType(ContentResource.QuickReplyActionType.QuickReply)
        .WithTitle("Yes")
        .WithId("yes_option")
        .Build()
};

var quickReplyContent = new ContentResource.TwilioQuickReply.Builder()
    .WithBody("Would you like to receive updates?")
    .WithActions(actions)
    .Build();

var contentTypes = new ContentResource.Types.Builder()
    .WithTwilioQuickReply(quickReplyContent)
    .Build();

var content = ContentResource.Create(new ContentResource.ContentCreateRequest.Builder()
    .WithFriendlyName("Update Subscription")
    .WithLanguage("en")
    .WithTypes(contentTypes)
    .Build());

These examples provide developers with ready-to-use code patterns for implementing rich, interactive messaging experiences using the Content API's JSON-based architecture.

Fixes #795.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Author

Copilot AI commented Aug 20, 2025

@tiwarishubham635 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI and others added 2 commits August 20, 2025 18:08
@Copilot Copilot AI changed the title [WIP] Content API code sample? Add comprehensive Content API code examples for JSON-based content types Aug 20, 2025
@Copilot Copilot AI requested a review from tiwarishubham635 August 20, 2025 18:18
Copilot finished work on behalf of tiwarishubham635 August 20, 2025 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Content API code sample?
2 participants