telnyx-messaging-profiles-go

📁 team-telnyx/telnyx-ext-agent-skills 📅 2 days ago
3
总安装量
2
周安装量
#62569
全站排名
安装命令
npx skills add https://github.com/team-telnyx/telnyx-ext-agent-skills --skill telnyx-messaging-profiles-go

Agent 安装分布

opencode 2
gemini-cli 2
antigravity 2
claude-code 2
windsurf 2
github-copilot 2

Skill 文档

Telnyx Messaging Profiles – Go

Installation

go get github.com/team-telnyx/telnyx-go

Setup

import (
  "context"
  "fmt"
  "os"

  "github.com/team-telnyx/telnyx-go"
  "github.com/team-telnyx/telnyx-go/option"
)

client := telnyx.NewClient(
  option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
)

All examples below assume client is already initialized as shown above.

List messaging profiles

GET /messaging_profiles

	page, err := client.MessagingProfiles.List(context.TODO(), telnyx.MessagingProfileListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)

Create a messaging profile

POST /messaging_profiles — Required: name, whitelisted_destinations

Optional: ai_assistant_id ([‘string’, ‘null’]), alpha_sender ([‘string’, ‘null’]), daily_spend_limit (string), daily_spend_limit_enabled (boolean), enabled (boolean), health_webhook_url (url), mms_fall_back_to_sms (boolean), mms_transcoding (boolean), mobile_only (boolean), number_pool_settings ([‘object’, ‘null’]), resource_group_id ([‘string’, ‘null’]), smart_encoding (boolean), url_shortener_settings ([‘object’, ‘null’]), webhook_api_version (enum), webhook_failover_url (url), webhook_url (url)

	messagingProfile, err := client.MessagingProfiles.New(context.TODO(), telnyx.MessagingProfileNewParams{
		Name:                    "My name",
		WhitelistedDestinations: []string{"US"},
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", messagingProfile.Data)

Retrieve a messaging profile

GET /messaging_profiles/{id}

	messagingProfile, err := client.MessagingProfiles.Get(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", messagingProfile.Data)

Update a messaging profile

PATCH /messaging_profiles/{id}

Optional: alpha_sender ([‘string’, ‘null’]), created_at (date-time), daily_spend_limit (string), daily_spend_limit_enabled (boolean), enabled (boolean), id (uuid), mms_fall_back_to_sms (boolean), mms_transcoding (boolean), mobile_only (boolean), name (string), number_pool_settings ([‘object’, ‘null’]), record_type (enum), smart_encoding (boolean), updated_at (date-time), url_shortener_settings ([‘object’, ‘null’]), v1_secret (string), webhook_api_version (enum), webhook_failover_url (url), webhook_url (url), whitelisted_destinations (array[string])

	messagingProfile, err := client.MessagingProfiles.Update(
		context.TODO(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.MessagingProfileUpdateParams{},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", messagingProfile.Data)

Delete a messaging profile

DELETE /messaging_profiles/{id}

	messagingProfile, err := client.MessagingProfiles.Delete(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", messagingProfile.Data)

List phone numbers associated with a messaging profile

GET /messaging_profiles/{id}/phone_numbers

	page, err := client.MessagingProfiles.ListPhoneNumbers(
		context.TODO(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.MessagingProfileListPhoneNumbersParams{},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)

List short codes associated with a messaging profile

GET /messaging_profiles/{id}/short_codes

	page, err := client.MessagingProfiles.ListShortCodes(
		context.TODO(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.MessagingProfileListShortCodesParams{},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)

List Auto-Response Settings

GET /messaging_profiles/{profile_id}/autoresp_configs

	autorespConfigs, err := client.MessagingProfiles.AutorespConfigs.List(
		context.TODO(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.MessagingProfileAutorespConfigListParams{},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", autorespConfigs.Data)

Create auto-response setting

POST /messaging_profiles/{profile_id}/autoresp_configs — Required: op, keywords, country_code

Optional: resp_text (string)

	autoRespConfigResponse, err := client.MessagingProfiles.AutorespConfigs.New(
		context.TODO(),
		"profile_id",
		telnyx.MessagingProfileAutorespConfigNewParams{
			AutoRespConfigCreate: telnyx.AutoRespConfigCreateParam{
				CountryCode: "US",
				Keywords:    []string{"keyword1", "keyword2"},
				Op:          telnyx.AutoRespConfigCreateOpStart,
			},
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", autoRespConfigResponse.Data)

Get Auto-Response Setting

GET /messaging_profiles/{profile_id}/autoresp_configs/{autoresp_cfg_id}

	autoRespConfigResponse, err := client.MessagingProfiles.AutorespConfigs.Get(
		context.TODO(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.MessagingProfileAutorespConfigGetParams{
			ProfileID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", autoRespConfigResponse.Data)

Update Auto-Response Setting

PUT /messaging_profiles/{profile_id}/autoresp_configs/{autoresp_cfg_id} — Required: op, keywords, country_code

Optional: resp_text (string)

	autoRespConfigResponse, err := client.MessagingProfiles.AutorespConfigs.Update(
		context.TODO(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.MessagingProfileAutorespConfigUpdateParams{
			ProfileID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
			AutoRespConfigCreate: telnyx.AutoRespConfigCreateParam{
				CountryCode: "US",
				Keywords:    []string{"keyword1", "keyword2"},
				Op:          telnyx.AutoRespConfigCreateOpStart,
			},
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", autoRespConfigResponse.Data)

Delete Auto-Response Setting

DELETE /messaging_profiles/{profile_id}/autoresp_configs/{autoresp_cfg_id}

	autorespConfig, err := client.MessagingProfiles.AutorespConfigs.Delete(
		context.TODO(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.MessagingProfileAutorespConfigDeleteParams{
			ProfileID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", autorespConfig)

List short codes

GET /short_codes

	page, err := client.ShortCodes.List(context.TODO(), telnyx.ShortCodeListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)

Retrieve a short code

GET /short_codes/{id}

	shortCode, err := client.ShortCodes.Get(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", shortCode.Data)

Update short code

Update the settings for a specific short code.

PATCH /short_codes/{id} — Required: messaging_profile_id

Optional: tags ([‘array’])

	shortCode, err := client.ShortCodes.Update(
		context.TODO(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.ShortCodeUpdateParams{
			MessagingProfileID: "abc85f64-5717-4562-b3fc-2c9600000000",
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", shortCode.Data)