Send an SMS with Thinwrap (Erlang)

Send an SMS via thinwrap_notifications:send_sms/2 in Erlang — one call shape for Twilio, Vonage, MessageBird and every other provider.

1. Install

{deps, [{thinwrap_notifications, "~> 1.2"}]}.

2. Send the call

Config = #{provider => twilio,
           account_sid => list_to_binary(os:getenv("TWILIO_ACCOUNT_SID")),
           auth_token => list_to_binary(os:getenv("TWILIO_AUTH_TOKEN")),
           from => <<"+15551112222">>},

case thinwrap_notifications:send_sms(Config, #{
    to => <<"+15552223333">>,
    body => <<"Hello from Thinwrap">>
}) of
    {ok, #{status := Status, provider_message_id := Id}} ->
        io:format("~s ~s~n", [Status, Id]);
    {error, #{code := Code, message := Msg}} ->
        io:format("~s: ~ts~n", [Code, Msg])
end.

Same code works for all supported providers — just change the provider ID.