Using response to duplicate event to different team

Not Yet Reviewed

We are wanting to create response options that route an event to a particular team based on the response chosen.

I'm guessing that this can be done via outbound integration tying the response identifier to a specific group, but generating a duplicate event via the transform script is where we are running into issues.

If anyone has ever done this before, or has a better understanding of how to do a duplication via the integration builder we'd appreciate some insight.



Date Votes

Please sign in to leave a comment.

  • Hey Chris,

       I'm working on putting something together that will help show off this kind of thing. But to get you started, here are some pointers:

    1. The response value can be accessed with "callback.response". This is the text value in the Response column on the Responses section of the form. This is human readable for easy access. 

    2. You can reference properties of the "parent" event using "callback.eventProperties.propertyName". If your property name has spaces or special characters, you can use "callback.eventProperties[ "My Funky's property" ]". Just note that the eventProperties is hard to work with by itself, but every new script in the builder has a section for looping through and updating this to be easy to work with. Check out the scriptlet at the bottom of this post. 

    3. You just make a web service call like any other and target the Form endpoint url. Just copy the path portion and paste it into the path value of the http request object. 

    You can use this scriptlet to get you started:

    if( callback.response == 'Do Stuff' ) {

    // Get info from the previous event
    var item = callback.eventProperties.item1;

    // Build the event request
    var getEvents = http.request({
    'endpoint': 'xMatters',
    'method': 'POST',
    'path': '/api/integration/1/functions/UUID/triggers'

    // Figure out who to target
    var recipients = [];
    recipients.push({ "targetName": "group" });

    // Build the event payload
    var payload = {
    "subject" : 'Subject here',
    "message" : 'Message here',
    "item1" : item,
    "recipients" : recipients

    // Submit the request and capture the response
    // Response will look like this: https://help.xmatters. com/OnDemand/xmodwelcome/communicationplanbuilder/appendixrestapi.htm#POSTtrigger
    var response = getEvents.write( payload );



    This is the section of code you'll need to deal with the ugly nature of the eventProperties. Fortunately, this gets copied into newly created scripts, but I include it here for reference:

    // Convert list of event properties to an eventProperties object
    if (callback.eventProperties && Array.isArray(callback.eventProperties)) {
    var eventProperties = callback.eventProperties;
    callback.eventProperties = {};

    for (var i = 0; i < eventProperties.length; i++) {
    var eventProperty = eventProperties[i];
    var key = Object.keys(eventProperty)[0];
    callback.eventProperties[key] = eventProperty[key];

    // Handle responses without annotations
    if (callback.annotation == "null") {
    callback.annotation = null;

    With this code in place, you can reference the properties like this:

    var myItem = callback.eventProperties.item1;

    Instead of needing to loop through the entire eventProperties array and checking the name just to get the value. Not pretty. 


    I hope that helps. 

    Let me know if you have more questions!

    Happy Monday!
        --- Travis

  • Ha. I knew it was a good idea to write this up... So much so that I apparently did it already!

    GIG: Follow up notification based on response with bonus QR codes!

    I had to make a couple updates to reflect some UI changes, but the rest of it is good info. 

  • Thanks Travis, I appreciate you pointing us in the right direction


Didn't find what you were looking for?

New post