Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
227
twilio.go1.34 kB
package sms import ( "context" "fmt" "log/slog" "github.com/Southclaws/fault" "github.com/Southclaws/fault/fctx" "github.com/Southclaws/fault/fmsg" "github.com/twilio/twilio-go" twilioApi "github.com/twilio/twilio-go/rest/api/v2010" "github.com/Southclaws/storyden/internal/config" ) var errFailedToSend = fault.New("failed to send sms") type TwilioSender struct { client *twilio.RestClient number string } func newTwilio(l *slog.Logger, cfg config.Config) (Sender, error) { client := twilio.NewRestClientWithParams(twilio.ClientParams{ Username: cfg.TwilioAccountSID, Password: cfg.TwilioAuthToken, }) acc, err := client.Api.FetchAccount(cfg.TwilioAccountSID) if err != nil { return nil, fault.Wrap(err) } l.Info("twilio enabled", slog.String("account_id", *acc.Sid)) return &TwilioSender{ client: client, number: cfg.TwilioPhoneNumber, }, nil } func (s *TwilioSender) Send(ctx context.Context, phone string, message string) error { params := &twilioApi.CreateMessageParams{} params.SetFrom(s.number) params.SetTo(phone) params.SetBody(message) resp, err := s.client.Api.CreateMessage(params) if err != nil { return fault.Wrap(err, fctx.With(ctx)) } if resp.ErrorCode != nil { return fault.Wrap(errFailedToSend, fmsg.With(fmt.Sprintf("error code: %d", *resp.ErrorCode))) } return nil }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Southclaws/storyden'

If you have feedback or need assistance with the MCP directory API, please join our Discord server