// This script asks the user a series of job interview questions. // You can edit this script to define your own questions. state Interview { pattern "start" answer start(); pattern "init questions" answer init(); pattern "*" topic "interview" answer interview(); function init() { if (!speaker.has(#associated, #administrator)) { return null; } #interview.question = null; #interview.question =+ { question : "What is your full name?", value : #name }; #interview.question =+ { question : "What is your email address?", value : #emailaddress }; #interview.question =+ { question : "What is your phone number?", value : #phone }; #interview.question =+ { question : "Which job are you applying for?", value : #job }; #interview.question =+ { question : "Are you presently employeed? ", value : #employeed }; #interview.question =+ { question : "Who was your last employeer?", value : #employeer }; #interview.question =+ { question : "Do you have a university or college degree? ", value : #college, followup : { "Yes" : "What is your degree in?", value : #degree } }; #interview.question =+ { question : "How many years of experience do you have in this industry?", value : #experience }; #interview.question =+ { question : "What city, state, and country are you current living in?", value : #address }; #interview.question =+ { question : "When are you available to start?", value : #startDate }; #interview.question =+ { question : "What salary range do you expect to earn?", value : #salary }; return "Interview questions initialized."; } function start() { conversation.topic = "interview"; conversation.questionNumber = 0; conversation.resume = new Resume(); return "I am going to ask you a series of questions related to our job positions available. Please answer the questions honestly."; } // Each question is asked in order, with possible followup questions. // A question index is used to track the current question. // The answers are stored in a Resume object and emailed to hr. function interview() { var question = conversation.question; var resume = conversation.resume; if (question != null) { resume.set(question.value, star.toString()); conversation.resume.append(#question, question.value); if (question.followup != null) { var followup = question.followup.get(star.toString().toSymbol()); if (followup != null) { conversation.question = question.followup; return followup; } } } conversation.questionNumber = conversation.questionNumber + 1; var questionNumber = conversation.questionNumber; var total = #interview.size(#question); if (questionNumber < total) { var question = #interview.get(#question, questionNumber - 1); if (question != null) { conversation.question = question; return question.question; } } #resumes.instance =+ resume; message = "

Resume

"; for (key in resume.question) { message = message + key.substring(1, key.length()) + " : " + resume[key] + "
"; } Email.email("careers@acme.com", "New resume", message); conversation.topic = null; conversation.questionNumber = null; conversation.resume = null; return "Thank you for the interview, someone will be in contact with you in a few days if we desire a follow up interview."; } }