sclass Handover { sclass Form_DoYouWantAHuman > FormInFlight { *() { steps.add(nu FormStep( key := "answer", displayText := "Would you like to be connected to a sales representative?", buttons := ll("Yes", "No") )); } S complete() { if (isYes(getValue("answer"))) { conversation.setForm(new ConnectToWorkerForm); ret ""; } } } S handleHashtag(Conversation conv, S tag) null { if (eqic(tag, "#ConnectMeToAHuman")) ret tryToConnect(conv); if (eqic(tag, "#DoYouWantAHuman")) { setForm(new Form_DoYouWantAHuman); ret ""; // Text comes from Q&A admin } } S tryToConnect(Conversation conversation) { if (workerChat.anyWorkersAvailable()) { conversation.setForm(new ConnectToWorkerForm); ret ""; } else ret noWorkerAvailableMsg(); } sclass ConnectToWorkerForm > FormInFlight { S initialMessage() { addTimeout(20.0, this); ret "I will try to connect you to a sales representative, just a moment..."; } void onWorkerAccepts(Worker worker) { // turn off bot done elsewhere // mark conversation as connected to worker done elsewhere conversation.cancelForm(); // cancel this form conversation.add(new Msg("Great news! I found a representative who is available to chat with you. Please wait just another second for them to respond.", false)); } void onTimeout() { /*new NoWorkerAvailable form; conversation.setForm(); conversation.add(new Msg(form.initialMessage(), false));*/ conversation.add(new Msg(noWorkerAvailableMsg(), false)); } } S noWorkerAvailableMsg() { ret "I am sorry, currently no worker is available. Please use our contact form."; } }