Skip to content

VA Notify External Service Integration

minhazur9 edited this page Sep 13, 2022 · 14 revisions

Sending the Job to the Queue

A payload gets generated and sent as an argument for an active rails job called SendNotificationJob which gets queued up to the "send_notifications.fifo" queue.

Performing the Job

The perform method for SendNotificationJob will get triggered and start processing the payload it has received to get it ready to send it to the VA Notify Service.

VA Notify Service

The VA Notify Service is how we interact with the VA Notify API, its used as an interface to access its endpoints. We will be sending an Email or an SMS depending on what the appellant that we are sending the notification to has opted in for. Once we get a response back will be updating the notification record's content field

Sending an Email

We will be using the API endpoint that is used for sending out emails and the body that is requested for doing this is:

  • template_id
  • reference
  • recipient_identifier
  • personalisation
  • status

Template ID is the unique value for using the correct email template

Reference is the ID that gets generated after we created the notification record and what we will be using when we need to update the record

Recipient Identifier is an object that has two attributes, an id_type (which will be "PID" for participant ID) and id_value (which is the participant ID)

Personalisation is an object with dynamic attributes which depend on the template that is getting used. For example "Quarterly Notifications" requires personalisation which needs an appeal_status attribute which is just a string for status

Status is just going to be the current validity of the message, ex. participant_id is invalid

{
    body: {
      template_id: email_template_id,
      reference: notification_id,
      recipient_identifier: {
         id_type: "PID",
         id_value: participant_id
      },
     personalisation: {}
    },
    headers: HEADERS,
    endpoint: SEND_EMAIL_NOTIFICATION_ENDPOINT, method: :post
}

Sending an SMS

We will be using the API endpoint that is used for sending out sms and the body that is requested for doing this is:

  • template_id
  • reference
  • recipient_identifier
  • sms_sender_id
  • personalisation
  • status

Template ID is the unique value for using the correct sms template

Reference is the ID that gets generated after we created the notification record and what we will be using when we need to update the record

Recipient Identifier is an object that has two attributes, an id_type (which will be "PID" for participant ID) and id_value (which is the participant ID)

SMS Sender ID is the ID of the sender that will send the sms to the appelleant

Personalisation is an object with dynamic attributes which depend on the template that is getting used. For example "Quarterly Notifications" requires personalisation which needs an appeal_status attribute which is just a string for status

Status is just going to be the current validity of the message, ex. "Success"

{
    body: {
      template_id: sms_template_id,
      reference: notification_id,
      recipient_identifier: {
         id_type: "PID",
         id_value: participant_id
      },
      sms_sender_id: SENDER_ID || "",
      personalisation: {}
    },
    headers: HEADERS,
    endpoint: SEND_SMS_NOTIFICATION_ENDPOINT, method: :post
}

image

Clone this wiki locally