PJextra

PJextra

Example on how to implement "forms" within channels

I would like to have a way of an admin to get real time notifications every time a user submits a form and be able to chat with him if desired.
I couldn’t find any suitable example for this use case as:

  1. I think forms because:
    a) the user could be an unregistered user;
    b) the admin could be away and as such it should look/work like a form, not a chat;
    c) I want to save everything in the database and have different views on data;
  2. I think channels because:
    a) I would like to get instant alert that a form was submitted;
    b) I could want to reply immediately and start a chat;

I would like to have some feedback about the best approach, so I would greatly appreciate if someone could give some guiding lines or recommend any blog post/article on this.
Thanks,

Paulo Janeiro

Most Liked

shavit

shavit

Did you try to save from the channel, or publish to the channel from the controller?

def contact(conn, _params) do
   changeset = ...
   case Repo.insert(changeset) do
   ...
   AppName.Endpoint.broadcast("contact_forms:#{id}", "action_name", payload)
   ...
end

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

We're in Beta

About us Mission Statement