twilio-go

repository·main·Indexed 18 days ago

https://github.com/twilio/twilio-go

The official Go client library for the Twilio API, allowing developers to programmatically interact with Twilio services such as SMS and Voice. The library is largely auto-generated from OpenAPI specifications and supports Go versions 1.18 through 1.24. It includes functionality for initializing RestClients, generating TwiML responses, validating requests, and building access tokens for Twilio Client SDKs.

Tokens
378.3K
Snippets
790
Records
1.2K
Agent score
63%

What's inside twilio-go

  1. Overview of Conversations v2 API capabilities

    main

    The Conversations v2 API allows you to manage configurations, conversations, participants, and communications.

    Key workflows include:

    • Configurations: Define capture rules and channel settings.
    • Conversations: Group related communications together.
    • Participants: Manage the entities involved in a conversation.
    • Communications: Handle the actual messages and interactions within a conversation.
  2. Manage Conference Participants via AccountsConferencesParticipantsApi

    main

    The AccountsConferencesParticipantsApi provides endpoints to manage individual participants within a specific Twilio Conference. You can create new participants, fetch details for an existing participant, list all participants in a conference, update participant properties, or remove (kick) a participant from a conference.

    All API requests are relative to https://api.twilio.com.

    | Method | HTTP request | Description |
    ------------- | ------------- | ------------- |
    | [**CreateParticipant**](#CreateParticipant) | **Post** /2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants.json | |
    | [**DeleteParticipant**](#DeleteParticipant) | **Delete** /2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json | Kick a participant from a given conference |
    | [**FetchParticipant**](#FetchParticipant) | **Get** /2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json | Fetch an instance of a participant |
    | [**ListParticipant**](#ListParticipant) | **Get** /2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants.json | Retrieve a list of participants belonging to the account used to make the request |
    | [**UpdateParticipant**](#UpdateParticipant) | **Post** /2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json | Update the properties of the participant |
  3. Manage SIPREC resources via AccountsCallsSiprecApi

    main

    The AccountsCallsSiprecApi allows you to manage SIPREC (Session for Internet Protocol Control eXchange) resources associated with specific Twilio Calls. You can create new SIPREC resources or stop existing ones using their SID or the name assigned during creation.

    All API requests are relative to https://api.twilio.com.

  4. How client.BaseClient works as an abstraction

    main

    The client.BaseClient is an abstraction used by the Twilio Go helper library to allow users to plug in any implementation of an HTTP client. This design enables:

    • Proxy Support: Injecting an http.Client configured with specific Transport settings.
    • Request Interception: Overriding request/response logic via custom implementations.
    • Testing/Mocking: Providing a mock implementation of the client to simulate Twilio API responses during unit and integration tests without making real network calls.
  5. Format communication addresses for ConversationsV2Participant

    main

    When working with the Addresses property of a ConversationsV2Participant, the format of the address depends on the communication channel being used:

    • SMS/VOICE: Use E.164 format (e.g., "+18005550100")
    • EMAIL: Use a standard email address (e.g., "user@example.com")
    • WHATSAPP: Use the phone number with the whatsapp: prefix (e.g., "whatsapp:+18005550100")
    • RCS: Use a Sender ID or a phone number with the rcs: prefix (e.g., "rcs:brand_acme_agent" or "rcs:+18005550100")
  6. Understand the ExtractionResult model

    main
    The ExtractionResult object represents the output generated by a Twilio Intelligence Operator. It contains metadata about the execution, the specific operator used, and the structured data extracted from a conversation. The structure of the Result field is determined by the OutputFormat property set on the Operator that generated the result.
  7. Understand Conversational Intelligence API resources

    main

    The Conversational Intelligence API is organized into three primary resource types:

    • Configurations: Use the Configurations resource to create and manage intelligence configurations. These define rules that control how and when language operators analyze and transform conversations.
    • Operators: Use the Operators resource to create custom language operators or to retrieve existing Twilio-authored and custom operators.
    • Conversations & OperatorResults: Use the Conversations resource to retrieve conversations that have been processed with an intelligence configuration, and use the OperatorResults resource to retrieve the specific language operator results for those conversations.
  8. Understand the NumbersV2EndUserType model

    main
    The NumbersV2EndUserType model represents a configuration for an End-User Type within the Twilio Numbers V2 API. It defines the structure and required information (fields) that must be collected when creating an End-User. The specific fields required for an End-User will vary depending on whether the user is an individual or a business and may change based on evolving regulatory requirements.
  9. Define Prompt and Training Examples for Custom Language Operators

    main

    The LanguageOperatorVersion resource allows you to define custom behavior using Prompt and TrainingExamples.

    • Prompt: Natural language instructions used by the operator. You can reference runtime parameters using the {{parameters.[param_name]}} syntax.
    • TrainingExamples: An array of input/output pairs used to guide the model's understanding of expected behavior.

    Important Note on Visibility: These fields are only exposed for Custom Operators (where author is SELF). For Twilio-authored operators (author is TWILIO), the Prompt and TrainingExamples will be omitted from the API response.

  10. Understand Voice Dialing Permissions Hour Prefixes

    main

    In the context of Voice Dialing Permissions, a Prefix is a contiguous number range for a block of E.164 numbers that includes the E.164 assigned country code.

    When defining a prefix, it acts as a pattern matcher for a range of numbers. For example, a North American Numbering Plan (NANP) prefix like +1510720 (which can be represented as +1(510) 720) matches all numbers in the inclusive range from +1(510) 720-0000 to +1(510) 720-9999.

    // Example Prefix Concept:
    // +1510720 matches the range [+15107200000 to +15107209999]