Skip to content

Worker Processes

Scott Reynen edited this page Jul 25, 2017 · 2 revisions

Spoke has several processes that perform various tasks outside the main server process. The code for these tasks lives in /src/workers.

incoming-message-handler.js

When messages come in to the main server at /twilio, they are saved to the database in the pending_message_part table, but not processed. This task processes the messages, and eventually calls saveNewIncomingMessage() to save them to the campaign_contact table.

job-handler.js

This process handles 4 different types of tasks:

  1. campaign exports
  2. uploaded contacts
  3. assigning texters
  4. creating interaction steps

All of these jobs are saved in the job_request table when they're initially requested, and after processing, the results are saved to various other tables.

message-sender-*.js

These processes take messages with send_status of 'QUEUED' out of the message table, and send them via the appropriate service, where the send_status is changed to SENT or some error status. Each script processes a subset of messages based on the first digit in the recipient's phone number.

number-assigner.js

This process adds the user_number to outgoing messages. user_number is the number that sends the message. It will default to the number that sent the last message to the recipient. Otherwise, it will pick the first number assigned to the texter. Any texter who doesn't have a number assigned already will request one from the service sending the message (e.g. Twilio).

Clone this wiki locally