Guest User

Untitled

a guest
Nov 17th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. # Events
  2.  
  3. We add a new type of Vumi Go message, similar to a VumiApiCommand to handle events:
  4.  
  5. VumiApiEvent:
  6. account_key
  7. conversation_key
  8. conversation_type
  9. event_type
  10. event_data
  11.  
  12. A kind of event is uniquely identified by `conversation_type` and `event_type`, and `event_data` is a dict. All events go to an event dispatcher (either part of or similar to the command dispatcher) which looks up what needs to happen with each event and does the appropriate things.
  13.  
  14. # Event sources
  15.  
  16. Event sources generate and publish events.
  17.  
  18. All application/conversation workers are potential event sources. We may want to have some additional non-conversation event sources as well at some point.
  19.  
  20. # Event handlers
  21.  
  22. Event handlers are pieces of code (perhaps workers, perhaps part of the event dispatcher) that accept an event and then do something with it. Handlers would have to be specific to certain event types, but could also be event sources and fire their own events in response to things the're handling.
  23.  
  24. For example: A vxpolls conversation could fire a `poll_complete` event containing the poll results when someone finishes filling in a poll. The account has a `create_contact` handler listening for `poll_complete` events from that particular conversation, and configured to extract certain values from the poll data to create a contact with.
  25.  
  26. # Configuration
  27.  
  28. Event handlers would have to be configured in the UI somewhere, probably in a manner similar to a conversation start. Perhaps this kind of flow:
  29.  
  30. 1. Create new event handler
  31. 2. Select event source and type
  32. 3. Select event handler type
  33. 4. Configure handler-specific options
  34. 5. Profit!
  35.  
  36. We'd need to be able to chain handlers, so we could create a new contact and then send an SMS when a poll finishes.
  37.  
  38. # Routing and tags
  39.  
  40. Not *entirely* event-related, but this might be a good place to set up account-level tag routing and such, perhaps with a default account-wide message handler that does something sane rather than just throwing all the messages on the floor.
Add Comment
Please, Sign In to add comment