# Post-Task Actions

Post-task actions run at the end of the task, after all the task requirements have been satisfied. You can use these options to return an acknowledgment response to the user to confirm the details in the task, and to run a Lua function that performs some final operation with the collected task requirements.

To configure post-task actions, you set the `post` object in the configuration object for an individual task.

The following table describes the properties that you can set in the `post` object.

Property | Type | Description
--- | --- | ---
`response` | string | (Optional) A string response to return to the user. For example, this might be a confirmation of the information that was collected in the task. You can include session and task variables, by inserting the variable ID in double curly brackets, for example `{{MYVARIABLE}}`. The variable must already be set in an earlier part of the task (for a task variable) or conversation session (for a session variable). You can optionally use the `task:` or `session:` prefix to specify the type of variable, for example `{{task:MYVARIABLE}}`. If you do not use a prefix, Answer Server searches for the variable in the task variables first, and then the session variables.
`lua` | string | (Optional) A lua function to run at the end of the task, for example to run an external process to complete the task. The function that you specify must accept a `taskUtils` object. See Lua Processing Scripts.
`routing` | object | (Optional) A string or configuration object that determines the task to run next. See Task Routing.

    {
       "initial_task" : "GREET",
       "tasks" : [
          {
             "id" : "GREET",
             "pre" : {
                "response" : "Hello and welcome to the Lunch Virtual Assistant."
             },
             "requirements" : [
                {
                   "id": "USER_NAME",
                   "prompt": "Before we get started, could you tell me your name?",
                   "scope": "session"
                }
             ],
             "post": {
                "response" : "Welcome, {{USER_NAME}}. How can we help you today?"
             }
          },
          {
             "id" : "LUNCH",
             "pre" : {
                "response" : "I can help you order some lunch."
             },
             "trigger" : {
                "regex" : {
                   "pattern" : "(Book|order) .* lunch"
                }
             },
             "requirements" : [
                {
                   "id" : "FOOD_TYPE",
                   "prompt" : "Do you feel like a sandwich or a panini?"
                },
                {
                   "id" : "FILLING",
                   "prompt" : "What filling would you like?"
                }
             ],
             "post" : {
                "response" : "All right, {{USER_NAME}}. We'll get you a {{FILLING}} {{FOOD_TYPE}} right away!",
                "lua" : "send_lunch_order",
                "routing" : "ANYTHING_ELSE"
             }
          }
       ]
    }

In this example, the final response in the `GREET` task uses the session variable `{{USER_NAME}}`. The final response in the `LUNCH` task uses the session variable `{{USER_NAME}}`, and the task variables `{{FILLING}}` and `{{FOOD_TYPE}}`.

This simple configuration might result in a conversation like the following example:

Hello and Welcome to the Lunch Virtual Assistant.
Before we get started, could you tell me your name?

Amy

Welcome, Amy. How can we help you today?

I'd like to book lunch.

I can help you order some lunch.
Do you feel like a sandwich or a panini?

Panini

What filling would you like?

Cheese

All right, Amy. We'll get you a Cheese Panini right away!

The task then runs the `send_lunch_order` Lua function, which might call out to an external system to set up the order. It routes the user to the `ANYTHING_ELSE` task.

© Copyright 2015-2020 Micro Focus or one of its affiliates | Send documentation feedback Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a mail client, and then send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm