App-in-the-Middle is a feature developed for Nfield, in which control of a survey is temporarily handed over to an external application, so that functionalities not offered within Nfield can be incorporated into survey execution. This is useful, for example, if you want to make use of a Sawtooth module for implementing a complex conjoint.
How it works
All you have to do is instruct your Nfield survey when to switch to the external app, and instruct the external app when to switch back to your survey. Making sure, of course, that all the relevant data is handed over during both switching processes.
Within Nfield, this is handled in the sense of pausing and resuming interviews. We’ve accommodated the App-in-the-Middle feature by making it possible to resume paused interviews from an “as is” status, in addition to the usual “as was” status.
“as was” vs “as is”
Under normal circumstances which don’t involve App-in-the-Middle, a paused Nfield Online or CAWI interview simply returns to its last-known state upon resuming, with all variables and routing restored to the point they were at when paused. This is known as resuming from the “as was”.
Incorporating App-in-the-Middle requires Nfield to accept changes made during the external app’s time in control and resume from this updated situation. This means resuming from the “as is” instead of the “as was”. We’ve introduced this option into Nfield, so you can now incorporate extra functionality via App-in-the-Middle whenever you need to.
How to implement App-in-the-Middle in your surveys
This short video shows the basic principles without going into too much detail.
Switching control between Nfield and an external app
Control over conducting the interview is handed over from Nfield to the external app by using the ODIN command: *ENDST 107
. This pauses the interview in Nfield and redirects to the relocation link defined for response code 107. The external app hands back to Nfield by redirecting to the survey URL with its corresponding respondent key and other information.
For the interview to continue in Nfield, some special script constructs must be used to prevent the interview executing *ENDST 107
again. This is done by using either the *INIT
block or information that is handed over from the external app. You can find out more about using *INIT blocks in our Academy session video on pausing and resuming surveys.
Handing information over to an external app
The relevant information can be handed over to an external app by adding it as query string parameters to the exit link configured for the HandedOver
response code (107).
For example:https://aitm.com?respondent={respondentKey}&extra={extraInfo}
This shows the names of ODIN variables between the {}. The variable names are replaced by the variable values before redirection to the external app’s URL.
Handing information back to the Nfield survey
The external app hands back to Nfield by redirecting to the survey URL. The survey URL must contain the respondentKey. Extra information can be added as query string parameters. The interview will then be resumed (from “as is”) with the ODIN variables having the values now shown in the query string parameters.
For example:https://{startlink}/{respondentKey}?aitmResult=199
This will resume the interview and if an ODIN variable with the name aitmResult is defined it will get the value 199.
Here to help!
Let us know if you want to integrate a specific app via App-in-the-Middle into your surveys. We’ll be happy to help you set up your project.