forked from politics-rewired/Spoke
-
Notifications
You must be signed in to change notification settings - Fork 2
feat(dialer): volunteer caller backend #205
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| nodejs 16.14.0 | ||
| nodejs 20.16.0 | ||
| yarn 1.22.19 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| export const schema = ` | ||
| type DialerCampaignContact { | ||
| id: ID! | ||
| campaignId: ID! | ||
| firstName: String! | ||
| lastName: String! | ||
| zip: String | ||
| callStatus: String! | ||
| doNotCall: Boolean! | ||
| attemptCount: Int! | ||
| lastAttemptedAt: Date | ||
| customFields: JSON! | ||
| assignment: Assignment | ||
| interactionSteps: [InteractionStep!]! | ||
| questionResponseValues: [DialerQuestionResponseValue!]! | ||
| tags: [Tag!]! | ||
| campaignVariables: [CampaignVariable!]! | ||
| } | ||
|
|
||
| type DialerQuestionResponseValue { | ||
| id: ID! | ||
| interactionStepId: ID! | ||
| question: String! | ||
| value: String! | ||
| } | ||
|
|
||
| # A past texting conversation with the same person (matched by phone), shown | ||
| # as context on the calling screen. One entry per prior campaign_contact. | ||
| type DialerContactConversation { | ||
| campaignId: ID! | ||
| campaignTitle: String! | ||
| contactId: ID! | ||
| firstName: String | ||
| lastName: String | ||
| messages: [Message!]! | ||
| } | ||
|
|
||
| type DialerCall { | ||
| id: ID! | ||
| dialerCampaignContactId: ID! | ||
| status: String! | ||
| fromNumber: String | ||
| telnyxCallControlId: String | ||
| createdAt: Date! | ||
| answeredAt: Date | ||
| endedAt: Date | ||
| } | ||
|
|
||
| type InitiateCallResult { | ||
| dialerCallId: ID! | ||
| contactPhone: String! | ||
| fromNumber: String! | ||
| } | ||
|
|
||
| type RequestCallShiftResult { | ||
| assignmentId: ID | ||
| campaignId: ID | ||
| count: Int! | ||
| } | ||
|
|
||
| input DialerQuestionResponseInput { | ||
| interactionStepId: String! | ||
| value: String! | ||
| } | ||
|
|
||
| input UpdateDialerCallInput { | ||
| status: String | ||
| telnyxCallControlId: String | ||
| answeredAt: String | ||
| endedAt: String | ||
| } | ||
| `; | ||
|
|
||
| export default schema; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| fragment CampaignListEntry on Campaign { | ||
| id | ||
| title | ||
| campaignType | ||
| isStarted | ||
| isApproved | ||
| isArchived | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| fragment DialerContactCore on DialerCampaignContact { | ||
| id | ||
| campaignId | ||
| firstName | ||
| lastName | ||
| zip | ||
| callStatus | ||
| doNotCall | ||
| attemptCount | ||
| lastAttemptedAt | ||
| customFields | ||
| campaignVariables { | ||
| id | ||
| name | ||
| value | ||
| } | ||
| questionResponseValues { | ||
| id | ||
| interactionStepId | ||
| question | ||
| value | ||
| } | ||
| tags { | ||
| id | ||
| title | ||
| description | ||
| confirmationSteps | ||
| onApplyScript | ||
| textColor | ||
| backgroundColor | ||
| isAssignable | ||
| isSystem | ||
| } | ||
| interactionSteps { | ||
| id | ||
| questionText | ||
| scriptOptions | ||
| answerOption | ||
| parentInteractionId | ||
| isDeleted | ||
| answerActions | ||
| question { | ||
| text | ||
| answerOptions { | ||
| value | ||
| nextInteractionStep { | ||
| id | ||
| scriptOptions | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| query GetNextDialerContact($assignmentId: String!) { | ||
| getNextDialerContact(assignmentId: $assignmentId) { | ||
| ...DialerContactCore | ||
| } | ||
| } | ||
|
|
||
| query GetDialerContact($dialerCampaignContactId: String!) { | ||
| getDialerContact(dialerCampaignContactId: $dialerCampaignContactId) { | ||
| ...DialerContactCore | ||
| } | ||
| } | ||
|
|
||
| query DialerContactTextingHistory($dialerCampaignContactId: String!) { | ||
| dialerContactTextingHistory( | ||
| dialerCampaignContactId: $dialerCampaignContactId | ||
| ) { | ||
| contactId | ||
| campaignId | ||
| campaignTitle | ||
| firstName | ||
| lastName | ||
| messages { | ||
| id | ||
| text | ||
| isFromContact | ||
| createdAt | ||
| } | ||
| } | ||
| } | ||
|
|
||
| mutation InitiateCall($assignmentId: String!, $dialerCampaignContactId: String!) { | ||
| initiateCall(assignmentId: $assignmentId, dialerCampaignContactId: $dialerCampaignContactId) { | ||
| dialerCallId | ||
| contactPhone | ||
| fromNumber | ||
| } | ||
| } | ||
|
|
||
| mutation UpdateDialerCall( | ||
| $dialerCallId: String! | ||
| $input: UpdateDialerCallInput! | ||
| ) { | ||
| updateDialerCall(dialerCallId: $dialerCallId, input: $input) { | ||
| id | ||
| status | ||
| telnyxCallControlId | ||
| answeredAt | ||
| endedAt | ||
| } | ||
| } | ||
|
|
||
| mutation SaveDialerQuestionResponses( | ||
| $dialerCampaignContactId: String! | ||
| $questionResponses: [DialerQuestionResponseInput!]! | ||
| ) { | ||
| saveDialerQuestionResponses( | ||
| dialerCampaignContactId: $dialerCampaignContactId | ||
| questionResponses: $questionResponses | ||
| ) { | ||
| ...DialerContactCore | ||
| } | ||
| } | ||
|
|
||
| mutation MarkDialerContactComplete( | ||
| $dialerCampaignContactId: String! | ||
| $callStatus: String! | ||
| ) { | ||
| markDialerContactComplete( | ||
| dialerCampaignContactId: $dialerCampaignContactId | ||
| callStatus: $callStatus | ||
| ) { | ||
| id | ||
| callStatus | ||
| attemptCount | ||
| lastAttemptedAt | ||
| } | ||
| } | ||
|
|
||
| mutation TagDialerContact( | ||
| $dialerCampaignContactId: String! | ||
| $tag: ContactTagActionInput! | ||
| ) { | ||
| tagDialerContact( | ||
| dialerCampaignContactId: $dialerCampaignContactId | ||
| tag: $tag | ||
| ) { | ||
| id | ||
| tags { | ||
| id | ||
| title | ||
| description | ||
| confirmationSteps | ||
| onApplyScript | ||
| textColor | ||
| backgroundColor | ||
| isAssignable | ||
| isSystem | ||
| } | ||
| } | ||
| } | ||
|
|
||
| query CallShiftAvailable($organizationId: String!) { | ||
| callShiftAvailable(organizationId: $organizationId) | ||
| } | ||
|
|
||
| mutation RequestCallShift($organizationId: String!) { | ||
| requestCallShift(organizationId: $organizationId) { | ||
| assignmentId | ||
| campaignId | ||
| count | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /** | ||
| * Record when a dialer call actually connected. Talk duration is then derived | ||
| * as ended_at - answered_at (created_at is the queue/dial-click time, which | ||
| * includes ring time, so it isn't a reliable start for talk duration). | ||
| * | ||
| * @param { import("knex").Knex } knex | ||
| * @returns { Promise<void> } | ||
| */ | ||
| exports.up = async function up(knex) { | ||
| await knex.schema.alterTable("dialer_call", (table) => { | ||
| table.timestamp("answered_at").nullable(); | ||
| }); | ||
| }; | ||
|
|
||
| /** | ||
| * @param { import("knex").Knex } knex | ||
| * @returns { Promise<void> } | ||
| */ | ||
| exports.down = async function down(knex) { | ||
| await knex.schema.alterTable("dialer_call", (table) => { | ||
| table.dropColumn("answered_at"); | ||
| }); | ||
| }; |
26 changes: 26 additions & 0 deletions
26
migrations/20260601000009_call-campaigns-allow-autoassign.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /** | ||
| * Call campaigns DO use autoassignment — it's how volunteers are handed shifts | ||
| * of dialer contacts to call. Drop the guard added in 20260601000001 that | ||
| * pinned is_autoassign_enabled = false for call campaigns. | ||
| * | ||
| * @param { import("knex").Knex } knex | ||
| * @returns { Promise<void> } | ||
| */ | ||
| exports.up = async function up(knex) { | ||
| await knex.raw(` | ||
| alter table all_campaign | ||
| drop constraint if exists call_campaigns_no_autoassign; | ||
| `); | ||
| }; | ||
|
|
||
| /** | ||
| * @param { import("knex").Knex } knex | ||
| * @returns { Promise<void> } | ||
| */ | ||
| exports.down = async function down(knex) { | ||
| await knex.raw(` | ||
| alter table all_campaign | ||
| add constraint call_campaigns_no_autoassign | ||
| check (type <> 'call' or is_autoassign_enabled = false); | ||
| `); | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: I think this should be a new
DialerCampagnContactTagtype which includestaggerto indicate who tagged the contact likeCampaignContactTagdoes