April 2024
Beginner to intermediate
224 pages
5h 7m
English
An SMS app needs two parties to make a conversation. Because this is a mock API, you’ll have to talk to yourself. The MockServer app includes a way to reply to messages, but it requires a new route to be created. Let’s add that and then use it from end to end.
Create lib/phone_app_web/controllers/webhook/twilio_controller.ex and add the following code:
| | defmodule PhoneAppWeb.Webhook.TwilioController do |
| | use PhoneAppWeb, :controller |
| | |
| | def sms(conn, params) do |
| | persist_message(params) |
| | |
| | conn |
| | |> put_resp_content_type("text/xml") |
| | |> send_resp(200, incoming_sms_response()) |
| | end |
| | |
| | defp persist_message(params) ... |
Read now
Unlock full access