Skip to content

Conversation

Copy link

Copilot AI commented Aug 20, 2025

This PR addresses the lack of comprehensive examples for Twilio's Content API by providing detailed usage patterns for all available content types that handle JSON payloads.

What's Added

1. Comprehensive Documentation (content.md)

Expanded the existing basic example to include detailed examples for all major content types:

  • twilio/text - Simple text messages with variable substitution
  • twilio/media - Messages with image/video/document attachments
  • twilio/card - Rich cards with titles, subtitles, media, and action buttons
  • twilio/list-picker - Interactive menus with selectable options
  • twilio/call-to-action - Action buttons for URLs, phone calls, and copy codes
  • twilio/quick-reply - Quick response buttons for user interactions
  • twilio/carousel - Multiple cards in horizontally scrollable format
  • twilio/location - Location sharing with coordinates and addresses

2. Simple Runnable Example (content_api_example.go)

A standalone executable example that demonstrates:

  • Creating the most common content types (text, media, card)
  • Listing existing content templates
  • Proper error handling and environment setup
  • Clear guidance when credentials are missing

3. Dedicated Documentation (content_api_README.md)

Quick reference guide including:

  • Content types overview table
  • Key concepts (variables, action types, error handling)
  • Authentication setup instructions
  • Links to additional resources

Code Examples

The examples show proper JSON payload construction for each content type:

// Creating a card with action buttons
cardActions := []content.CardAction{
    {
        Type:  content.CARDACTIONTYPE_URL,
        Title: "View Details",
        Url:   "https://example.com/product/123",
    },
    {
        Type:  content.CARDACTIONTYPE_PHONE_NUMBER,
        Title: "Call Support", 
        Phone: "+1234567890",
    },
}

twilioCard := &content.TwilioCard{
    Title:    "Premium Wireless Headphones",
    Subtitle: "High-quality sound with noise cancellation",
    Media:    []string{"https://example.com/headphones.jpg"},
    Actions:  cardActions,
}

contentType := &content.Types{TwilioCard: twilioCard}

Testing

All examples have been validated for:

  • ✅ Syntax correctness (successful compilation)
  • ✅ Proper type usage and required/optional fields
  • ✅ Error handling patterns
  • ✅ Environment variable setup guidance

Impact

This provides developers with:

  • Clear examples for all Content API content types
  • Understanding of JSON payload structure for each type
  • Best practices for error handling and authentication
  • Both comprehensive documentation and quick-start examples

Fixes #296.


✨ 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 changed the title [WIP] How to use Content API? Add comprehensive Content API examples with all content types Aug 20, 2025
Copilot AI requested a review from tiwarishubham635 August 20, 2025 18:16
Copilot finished work on behalf of tiwarishubham635 August 20, 2025 18:16
@Mohmmed-jad
Copy link

Identity and Access Management (IAM)

The Identity and Access Management section covers how to manage your accounts (projects), securely authenticate Twilio REST API requests, and best practices for accessing Twilio.

This section covers the following:

  • Basic introduction of how to get started with the Twilio REST API.
  • The Accounts section offers guidance on how to pick the right account architecture.
  • API Keys are the best way to authenticate API requests.
  • Credentials allow for Public Keys management. Products like Public Key Client Validation and Voice Recordings Encryption rely on those Credentials.
  • Public Key Client Validation helps organizations in compliance-heavy industries meet strict security requirements, such as not relying on shared secrets, validating the sender, or verifying message content.
  • Access Control helps manage user access and offers granular, product-specific roles that can be assigned at the organization, account, or subaccount level.
  • Single Sign-On mitigates compliance and security risks for organizations by giving businesses control over user authentication and user revocation via corporate mandated tools.
  • Twilio Connect allows you to obtain authorization to perform API functions on behalf of another Twilio account holder.

{
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"auth_token": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
"date_created": "2015-07-31T04:00:00Z",
"date_updated": "2015-07-31T04:00:00Z",
"url": "https://accounts.twilio.com/v1/AuthTokens/Promote"
}

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.

How to use Content API?

3 participants