Twelixir: My First Elixir Hex Package

Alvin Rapada
2 min readFeb 27, 2021

Being in this open-source community. I’m always fascinated by people willing to share their knowledge and make development a lot easier. Me being at the receiving end (most of the time), I somehow want to do the same, I’ve always wanted to contribute and create my own elixir hex package, at least in my own little way possible, help other developers too.

After developing a LiveView Chat App, I was tasked to integrate Twilio Conversations API onto it, I tried to look for packages available but I can’t find anything for the Twilio Conversation API specifically, so I thought, this is the chance I’ve been waiting for.

With the approval of the developer I am working with this, let me introduce you to:

Twelixir

Twilio Conversations API Integration for Elixir

Installation

The package can be installed by adding twelixir to your list of dependencies in mix.exs:

def deps do
[
{:twelixir, “~> 0.1.0”}
]
end

Prerequisite

def deps do
[
{:httpoison, “~> 1.8”},
{:jason, “~> 1.2”}
]
end

Setup

Go to your /config.exs and setup twelixir config keys:

config :twelixir,
twilio_access_token_id: “YOUR_TWILIO_ACCESS_TOKEN_ID”,
twilio_secret_key: “YOUR_TWILIO_SECRET_KEY”

Usage


defmodule YourAppModule do

alias Twelixir
def your_method(your_friendly_name, your_attrs) do
response = Twelixir.create_conversation(your_friendly_name, your_attrs)
# response = %{
# “account_sid” => “AXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”,
# “attributes” => your_attrs,
# “chat_service_sid” => “IXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”,
# “date_created” => “2021–02–25T09:01:41Z”,
# “date_updated” => “2021–02–25T09:01:41Z”,
# “friendly_name” => your_friendly_name,
# “links” => %{
# “messages” => “https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages",
# “participants” => “https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants",
# “webhooks” => “https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Webhooks"
# },
# “messaging_service_sid” => “MXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”,
# “sid” => “CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”,
# “state” => “active”,
# “timers” => %{},
# “unique_name” => nil,
# “url” => “https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
# }
end
end

Documentation: https://hexdocs.pm/twelixir

Github: https://github.com/alvnrapada/twelixir

This is just a small project of mine, and not 100% complete, I’m not really sure If I can maintain this on my own, but It's a good start, right 😅 ?

Hope this package can find someone(a developer) looking for the same thing, just like me a week ago. Thank you!

If you find this helpful, I’d appreciate a coffee 😊

Happy Coding!!

--

--