# Quick Start Guide

{% hint style="info" %}
If you have little experience with Scala or SBT, we recommend that you follow our [Getting Started guide](/getting-started/installation-tutorial.md) instead.
{% endhint %}

In your source file, import the Mechanical Turk adapter (Scala syntax):

```scala
import org.automanlang.adapters.mturk.DSL._
```

After that, initialize the AutoMan runtime with an MTurk config:

```scala
implicit val mt = mturk (
  access_key_id = "my key",         // your MTurk "access key"
  secret_access_key = "my secret",  // your MTurk "secret key" 
  sandbox_mode = true               // if true, run on MTurk sandbox
)
```

and then define your task:

```scala
def which_one() = radio(
  budget = 5.00,
  text = "Which one of these does not belong?",
  options = (
    "Oscar the Grouch",
    "Kermit the Frog",
    "Spongebob Squarepants",
    "Cookie Monster",
    "The Count"
  )
)
```

You may then call `which_one` just like an ordinary function (which it is). Note that AutoMan functions immediately return an `Outcome`, but continue to execute asynchronously in the background.  AutoMan builds on top of a Scala feature called a [future](https://docs.scala-lang.org/overviews/core/futures.html) to make this happen.

To access return values, pattern-match on the `Outcome`'s `answer` field, e.g.,

```scala
val outcome = which_one()

// ... do some other stuff ...

// then, when you want answers ...
val answer = outcome.answer match {
  case Answer(value, _, _) => value
  case _ => throw new Exception("Oh no!")
}
```

Other possible cases are `LowConfidenceAnswer` and `OverBudgetAnswer`. If you run out of money during a computation, a `LowConfidenceAnswer` will let you access to lower-confidence results. An `OverBudgetAnswer` signals that you didn't have enough money in your budget to begin with.

#### Cleanup of AutoMan Resources

Note that, due to AutoMan's design, you must inform it when to shut down, otherwise it will continue to execute indefinitely and your program will hang:

```scala
mt.close()
```

Alternately, you may wrap your program in an `automan` statement, and cleanup will happen automatically. This feature was [inspired](https://msdn.microsoft.com/en-us/library/vstudio/yh598w02%28v=vs.100%29.aspx) by the C# `using` statement:

```scala
automan(mt) {
  ... your program ...
}
```

We will add more documentation to this site in the near future. In the interim, please see the collection of sample programs in the `apps` directory.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.automanlang.org/technical-documentation/quick-start-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
