Skip to content

Instantly share code, notes, and snippets.

@okamanda
Created April 5, 2016 01:04
Show Gist options
  • Save okamanda/0853960ab90089a75dd96543cb2c65d2 to your computer and use it in GitHub Desktop.
Save okamanda/0853960ab90089a75dd96543cb2c65d2 to your computer and use it in GitHub Desktop.
voterConversation = new Conversation();
function RunConversation(voterConversation)
{
int challengenumber=0;
int questionnumber=0;
int calloutnumber=0;
print(“Hi “+voterConversation->ID+ “I can help you register to vote. I just need to ask you” + voterConversation->Complexity + “questions. Is that OK?”);
//Ask the inquirer the first set of Challenges
while (voterConversation->Challenge[challengenumber]==true)
{
response = ask(voterConversation->Challenge[challengenumber]);
if(response == ‘yes’)
{
print(“Sorry, you’re not eligible to vote”);
break;
return false;
}
challengenumber++;
}
//Assuming the inquirer answered the Challenges move on to the Conversation Questions
while (voterConversation->Questions[questionnumber]==true)
{
response_to_questions[questionnumber] = ask(voterConversation->Questions[questionnumber]);
}
//Assuming all the Conversation have been answered, then move on to the Callout questions
while (voterConversation->Callout[calloutnumber]==true)
{
//run a Callout based on the participant’s response to the state of residence question
stateOfResidence = voterConversation->Question->[0];
CalloutResponse = runCallout(voterConversation->Callout[‘stateOfResidence’], response_to_questions);
}
//With the response from the callout, send the inquirer the final answer that resolves his/her question)
print(CalloutResponse);
//Ask for confirmation that the participant’s question has been answered
response = ask(“Did I answer your question”);
if (response == ‘yes’)
{
voterConversation->Confirmation=true;
return true;
}
else {
print(voterConversation->Cavalry);
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment