We could implement our current roommate matching functionality in three different ways with the release of the new app.
To make this work, we need to adjust our current RoomBot code to talk to Ejabberd server instead of Twilio.
- Mobile client initiates a roommate matching request by caling the
initiateRoommateMatching
mutation - A request is sent to the elixir bot by the rails server
- Per user, Elixir bot keeps the progress status for the roommate matching questions
- Based on user's state machine, roombot uses the Twilio channel to convey the next question to the mobile client
- Mobile Client receives the possible answers for each question from chatbot through a set of attributes
options
andquestionId
- The user will choose an answer for the question
- The answer will be received by chatbot
- The chatbot will update
user_roommate_answers
table (owned by Rails database) - The process happens for all questions
- When the process is done, mobile client can query for the results of roommate matching
Chatbot will need to use ejabberd instead of twilio as messaging carrier.
- A roommate matching channel needs to be created per user on ejabberd side.
- All roommate matching questions will be sent over the roommate matching channel.
- All roommate matching answers will be send over the roommate matching channel.
- Clients will need to update to handle new Message Type
In this approach, the communication between Elixir chatbot and Rails server will stay the same.
- Adds unnecessary complexity
- Needs a series of collaboration between elixir-bot/ejabberd-server/Rails
- Probably needs involvement from Manish
- Elixir bot needs write access to
user_story_answers
table which is owned by Rails app
It works!
The same functionality could be implemented as a ejabberd bot.
- Mobile client initiates a roommate matchig request
- The request is received by ejabberd
- For each user, the bot keeps track of most recent answered
question_id
- Based on user's state machine, ejabberd conveys the next question to the mobile client
- The possible answers for each questions are received by mobile client from ejabberd server
- The user will choose an answer for the question
- The answer will be received by the bot
- The bot will issue a
redis
job and informs the Rails server about a new answer for a question for a certain user. For example:{ user_uuid: '1111', question_id: '13', answer_value: 5 }
- The process happens for all questions
- When the process is done, mobile client can query for the results of roommate matching
- No need for a separate elixir bot
- The logic could be encapsulated inside ejabberd server
- Still complex to implement
- Needs a lot of collaboration between ejabberd and rails
- Roommate matching questions and database IDs needs to be stored in ejabberd side
- ejabberd needs to keep track of user's progress in answering the questions
Instead of using the chat platform to convey the questions and answers from/to Rails server, the mobile clients will talk directly to Rails server.
This is the way we implemented roommate matching 2 years ago. It requires a change in the way that roomate matching question are presented and also the way the answers are received from the users. Probably we need to move to a form-based approach instead of a bot-based one.
- The mobile client receives the list of questions from the Rails. (Retrieving all the list at once would suggest that we would not be able to pick up where we left off. Alternatively, we could call a query that would return
currentRoommateMatchQuestion
or something equivelant.) - It will present the questions to the user in a form-based fashion and it will require an answer for each question
- For each answer, mobile client will call a GQL mutation to let the Rails server know about the new answers.
- At the end of the flow, user will see a list of roommate matching results
- No single point of failure. Mobile clients will talk directly with Rails servers and there is no need for a middle man
- Simplest to implement
- It's not a chatbot
- Eliminates reusing the exsiting
Chat View Controller
. Would need to either create a "Mock" Chat view controller or go with a new design.
Complexity of Implementation from backend perspective (higher-effort to lower-effort)
- Elixir Bot (large effort)
- Ejabberd Bot (large effort)
- Rails API (small effort)
Complexity of Implementation from mobile-client perspective (higher-effort to lower-effort)
- Rails API (medium effort)
- Elixir Bot (medium effort)
- Ejabberd Bot (small effort)