application

Summit Application object.

By using the summit.application library, you will have access to this object. There are ways to send application-specific data to an app from an external source. To do this, you would set the values of application_data and/or application_destination when calling the app. Then you can use the application object within that app to access this data.

Functions

Name Summary
exit

Exits the current application.

get_data

Application data, set by an external source.

get_destination

Application destination, set by an external source.

Fields

Name Type Summary
app_id

string

Application ID of the currently running Summit application.

application_type

string

Provider name of this application.

Functions : application

exit(return_value)

Exits the current application. This function ends the current running application. If this application was started by another Summit application by using channel.app(), then that application will resume where it left off.

Do not call channel.hangup if you are using this; Summit will automatically hangup your channel if appropriate. If you call channel.hangup, control will not be returned to your original application.

Parameters
Name Type Default Summary

return_value

string or number or nil

nil

Some value to return, in case this application is running because of another application calling channel.app

Returns
Type Summary

ApplicationResult

see channel.ApplicationResult for details.

Usage
-- Example of one app launching another, and having that app return a value using `application.exit()`

-------
-- App1
-- Call into this application, which then launches `App2`. Then process the exit value of that app.

local log = require("summit.log")

channel.answer()

channel.say("This is application 1. I'm going to call channel dot app, for application 2.")

-- 'App2' is the name of the app we want to launch
-- `channel.app()` returns an `ApplicationResult` object
local app_result = channel.app('App2')

log.info("app_result: "..app_result.exit_value)

-- Read back the exit value from App2
channel.say("The application result from app two was, "..
            app_result.exit_value..". Good bye.")

channel.hangup()



-------
-- App2
-- This application is launched via `channel.app()` execution in `App1`


-- Must import summit.application to access its fields and functions
local application = require("summit.application")
local log = require("summit.log")
local speech = require("summit.speech")

channel.answer()

local digits_prompt = speech("This is application two. "..
                             "Press any number followed by the pound sign.",
                             {voice="man"})

local digits = channel.gather({play=digits_prompt})
log.info(digits)

channel.say("Returning "..digits.." as the exit value to app 1.", {voice="man"})

-- Set the exit value for processing in `App1`.
application.exit(digits)
-- Do not call `channel.hangup()`. It will not return control to `App1`

get_data()

Application data, set by an external source. The most common source is from Routepoint.application_data.

Returns
Type Summary

string or table

If the application_data was valid JSON, this returns a table containing the decoded data; if not, this returns a string of whatever was submitted

Usage
-- Using `App1` from our original example above, application_data can specificed as `{ ["foo"]="bar" }`
-- by updating the `channel.app()` function call and adding the argument to options like so:

-------
-- App1
-- Update the code to look like this
local app_result = channel.app('App2', {application_data={ ["foo"]="bar" }})



-- Using the example from `App2` above, we can access our `application_data` using the
-- `get_data()` function which returns a string or table

-------
-- App2
-- Let's get our application_data which was set by `App1`

-- Returns a string or some json-encoded data depending on how we set the value in `App1`
local app_data = application.get_data()

-- Since we know the value of app_data was a table, we must call `tostring()` on it
log.info("Value of app_data: "..tostring(app_data))

-- If we access our key directly, we don't have to call `tostring()`
log.info("Value of foo: "..app_data["foo"])

get_destination()

Application destination, set by an external source. This will usually be whatever value is in Routepoint.application_destination.

Returns
Type Summary

string

Application-specific data about the destination

Usage
-- Using `App1` from our original example above, application_destination can specificed as "1234"
-- by updating the `channel.app()` function call and adding the argument to options like so:

-------
-- App1
-- Update the code to look like this
local app_result = channel.app('App2', {application_destination="1234"})


-------
-- App2
-- Let's get our application_destination which was set by `App1`
local app_dest = application.get_destination()
log.info("Value of app_dest: "..app_dest)

Fields : application

app_id

Type: string

Application ID of the currently running Summit application.

application_type

Type: string

Provider name of this application.