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"))) { new ConnectToWorkerForm form; setForm(form); ret form.initialMessage(); } } } S handleHashtag(Conversation conv, S tag) null { if (eqic(tag, "#ConnectMeToAHuman")) { if (workerChat.anyWorkersAvailable()) ret connectToWorker(); else ret noWorkerAvailable(); } if (eqic(tag, "#DoYouWantAHuman")) { setForm(new Form_DoYouWantAHuman); ret ""; // Text comes from Q&A admin } } 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 conv.cancelForm(); // cancel this form conv.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; conv.setForm(); conv.add(new Msg(form.initialMessage(), false));*/ conv.add(new Msg("I am sorry, currently no worker is available. Please use our contact form.", false)); } } }