Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VAN Integration - OptOut #1

Open
Arique1104 opened this issue Nov 16, 2023 · 15 comments
Open

VAN Integration - OptOut #1

Arique1104 opened this issue Nov 16, 2023 · 15 comments
Assignees

Comments

@Arique1104
Copy link
Collaborator

Arique1104 commented Nov 16, 2023

Reprioritized. Automatic way to opt-out back into the VAN for cleaner lists. Fully integrate the disconnected phone file. (scrubber 2.0) Eric B - demo VAN key Boris Martinez Stevie Ambroise Addison they/them Jordan MA

@Arique1104
Copy link
Collaborator Author

Arique1104 commented Nov 17, 2023

Priority:

  • Excel document
  • Spoke has ability to collect Opt-outs, but it's manual...we need to automate.

Desired behavior = Canvassed on what date and Phone Number updated.

Correct VAN API Endpoint?

  • People with vanID
  • Phone Model in the VAN OptInStatus
  • string
  • I = opt-in
  • U = unknown
  • O = opt-out

We are adding a contact attempt
Canvass Disposition - DO NOT TEXT
changes reporting

@Arique1104
Copy link
Collaborator Author

Edge Cases for Automated Reporting:

  • Manual Opt-Out = During a texting campaign a volunteer will see the response to stop and click opt-out.
  • Misspell Stop

@ericberglund117
Copy link
Collaborator

Breadcrumbs after discovery session

  • Manual opt out does not change optInStatus on phone object
  • is_opted_out key is true when manually opted out in the campaign contact table

@jb-cloud
Copy link
Collaborator

We know currently the endpoint used to send canvass responses to VAN uses https://api.securevan.com/v4/people/{vanId}/canvassResponses. That endpoint has additional parameters, that are currently unused, which can apply an opt-out status to a specific phone number. Utilizing the phone object appears to be the best path forward.

https://docs.ngpvan.com/reference/peoplevanidcanvassresponses

@Arique1104
Copy link
Collaborator Author

Resources:

  • POSTMAN API Check w/ VAN (successful updating of the phone object)

@Arique1104
Copy link
Collaborator Author

Arique1104 commented Nov 17, 2023

Hey Folks, I think I may have found where in the code the isOptedOut function gets utilized for the conversations of a campaign.

Lind 39 of src/lib/conversations.js

export function getContactsFilterForConversationOptOutStatus(
  includeNotOptedOutConversations,
  includeOptedOutConversations
) {
  let isOptedOut = undefined;
  if (!includeNotOptedOutConversations && includeOptedOutConversations) {
    isOptedOut = true;
  } else if (
    (includeNotOptedOutConversations && !includeOptedOutConversations) ||
    (!includeNotOptedOutConversations && !includeOptedOutConversations)
  ) {
    isOptedOut = false;
  }

  if (isOptedOut !== undefined) {
    return { isOptedOut };
  }

  return {};
}

Lind 39 of src/lib/conversations.js

@Arique1104
Copy link
Collaborator Author

What did you find?

  • Method to do it:
  • Post canvass response function in nvpvan action file we found a target of the canvass context that has a phone object attached to it where. wecan update the OptInStatus. That's what we want to change so that we can decide oh or zero (O of 0)
  • Identifying how we update that based on isoptedout key from a different phone table.
  • ext/action_handlers/line 973 in canvass context objects.
  • Third attribute is opt out! but must be fed the correct information

What will be prioritized tomorrow:

  • Can we just modify this function OR
  • Do we add a whole another fix later?
  • Might be a conditional part of if-statements.

@jb-cloud
Copy link
Collaborator

Moar Breadcrumbs!

/Spoke/src/extensions/action-handlers/ngpvan-action.js
lines 73-75 are using the phones object of the canvasscontext object, however they are only using two of the three params available. we will attempt to add in param #3 (smsOptInStatus) which covers optouts.

@ericberglund117
Copy link
Collaborator

Pathways:

  • src/server/models/campaign-contact.js ------ contains campaign contact schema with is_opted_out key/value (boolean)

@Arique1104
Copy link
Collaborator Author

QA Process:

  • When an administrator goes to campaign report
  • They show an error report from Twilio -133, that's the auto-opt-out from Carrier. Twilio doesn't even handle it.

@Arique1104
Copy link
Collaborator Author

They are deployed successfully through Heroku

@Arique1104
Copy link
Collaborator Author

Final thoughts:

  • Manual deploy
  • It all started with the message Jordan got before.
  • Things we have learned:
  • Getting everything else to work with the code is hard.
  • Getting the right environment set up - trying to get the correct environment set up so that we can test the code.
  • It's hard to test on VAN because there's no fake-data from the VAN, so you need real Twilio - which makes development SUCK!
  • The fact that we're not seeing the console.logs() bothers you the most.
  • actionhandler (did our van network not work)
  • REMEMBER THIS: This was working, we didn't change the environment variables, we started a campaign and now we can't load the action handler. What does that mean?
  • used to be ngpvan-action (that variable used to exist in ACTION_HANDELERS

TOMORROW'S PRIORITIES

  • Verify all environment variables are correctly enabled. Instructions here.
  • Copy steps on what the proper flow of data looks like for this opt-out QA procedure.
  • What is the contact and where is it being passed in?

@ericberglund117
Copy link
Collaborator

Found this contact object in src/extensions/contact-loaders/datawarehouse/index.js
Line 238

Possible representation of contact being passed into postCanvassResponse function

const contact = {
campaign_id: jobEvent.campaignId,
first_name: row.first_name || "",
last_name: row.last_name || "",
cell: formatCell,
zip: row.zip || "",
external_id: row.external_id ? String(row.external_id) : "",
assignment_id: null,
message_status: "needsMessage"
};

@Arique1104
Copy link
Collaborator Author

@ericberglund117, the above looks like we need to add the isOptedOut status into this contact object.

If we update this contact object to hold the correct key, so that it pulls the correct value later on in the functionality. That would be awesome!

@Arique1104
Copy link
Collaborator Author

Biggest Road Block

  • Dealing with the enviornment was pieced together for the majority of the day yesterday.
  • There are some things that. wecan figure out along the way.
  • We did find a semblence of a contact object. w/no key that identifies that the contact is opted out. Modify that to update the contact before. wepost the van API.

What's needed?

  • Jim a new org messaging service with credits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

5 participants