Context are important when dealing with complex skills. It allows you to define in which case your intent should be recognized.

In order to declare a context, you just to have to define your intent with valid_context/your_intent and use the request.agent.context method to switch at runtime. Here is an example.

from pytlas import training, intent

def en_training(): return """
  start something right now
  please start a context
  let's dance

  say something
  talk to me

def start_handler(request):
  # This line will switch to the context `started_intent` which means that
  # the interpreter will now be able to recognize the `started_intent/say` intent
  # we define earlier.
  # Till we switch to this context, `started_intent/say` could not be triggered.

  return request.agent.done()

def say(request)

  # Switch to the root context which is the None one so this handler could not be triggered anymore

  return request.agent.done()

# You can also override builtin intents such as __fallback__ and __cancel__ for
# your context.
# Here the fallback means every sentence not recognized by the interpreter when
# in the `started_intent` context will trigger this handler.
def fallback(request):
  request.agent.answer('Looks like you said %s' % request.intent.slot('text').first().value)

  return request.agent.done()