ConditionalWorkflow

command
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 4 Imported by: 0

README

Conditional Workflow

Defining a conditional step

// Conditional Step 2
acControlKB := getACControlKeyboard()
step2 := tbotworkflow.NewWorkflowStep("AC Action", "ACAction", "Please select an option", acControlKB)
// Define the conditional function based on the user input message for that step
step2.ConditionFunc = func(msg *tgbotapi.Message) string {
  if msg.Text == "Quick Start" {
		return "QuickStart"
	}
	if msg.Text == "Turn OFF" {
		return "OFF"
	}
	if msg.Text == "Temperature" {
		return "Temp"
	}
	return ""
}

Chaining the conditional step

// Conditional chaining of steps
// The keys of ConditionalNext should match the values returned by the steps ConditionFunc
step2.ConditionalNext["QuickStart"] = &step3QS
step2.ConditionalNext["OFF"] = &step3Off
step2.ConditionalNext["Temp"] = &step3Temp

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL