EmailAskUserResponse

Extract user's response from EmailAskUser reply. Returns the first textual response line of the provided entry that contains the reply body. Use ${lastCompletedTaskEntries} to analyze the previous playbook task containing the user's reply.

javascript · Common Scripts

Source

var res = executeCommand("getEntry", {"id":args.responseEntryId});
var prefix = args.prefix;
var suffix = args.suffix;

if (res[0].Type==entryTypes.note || res[0].Type==entryTypes.file) {
    text = res[0].Contents;
    if (prefix && text.startsWith(prefix)) {
        text = text.slice(prefix.length);
    }
    if (suffix && text.endsWith(suffix)) {
        text = text.slice(0, -1 * suffix.length);
    }
    text = text.replace(/<br\/?>/gi,'\n')
                .replace(/\r/g,'')
                .replace(/\n/g,'__NL__')
                .replace(/<script .+?<\/script>/g,'')
                .replace(/<style .+?<\/style>/g,'')
                .replace(/__NL____NL__/g,'')
                .replace(/__NL__/g,'\n');
    response = text.replace(/<(?:.|\n)*?>/gm, '').trim("\n").split("\n")[0].trim();
    setContext('EmailAskUserResponse', response);
    return response;
} else {
    return res;
}

README

Extract a user’s response from EmailAskUser reply. Returns the first textual response line of the provided entry that contains the reply body. Use ${lastCompletedTaskEntries} to analyze the previous playbook task containing the user’s reply.

Script Data


Name Description
Script Type javascript
Tags Condition

Inputs


Argument Name Description
responseEntryId The entry ID where EmailAskUser will complete when the user replies.
prefix Text to remove from the start of the answer. If the response contains a known prefix that should be removed, this argument should be used.
suffix Text to remove from the end of the answer. If the response contains a known suffix that should be removed, this argument should be used.

Outputs


There are no outputs for this script.