Configure onConversationCreate and onConversationUpdate

onConversationCreate

When a conversation is initiated by a user, the onConversationCreate event is invoked and the registered callback method is executed.

Subscribe to the onConversationCreate event and register the callback by using the following sample manifest.json content.

manifest.json
"events": {
  "onConversationCreate": {
    "handler": "onConversationCreateCallback"
  }
}

Define the corresponding callback by using the following sample server.js content:

server.js
exports = {
  onConversationCreateCallback: function(payload) {
    console.log("Logging arguments from onConversationCreate event: " + JSON.stringify(payload));
  }
}

Attributes of the data object

  • actorobject

    Details of the entity that triggered the onConversationCreate event.

    For onConversationCreate, it is a user.

  • associationsobject

    Associated objects related to the conversation object.

  • conversationobject

    Details of the conversation object created when the onConversationCreate event is triggered.

onConversationUpdate

The onConversationUpdate event is triggered in the Freshworks system when,

  • A conversation is assigned to an agent or a group.
  • An existing conversation is reassigned to an agent or unassigned from a group.
  • A conversation is resolved or reopened.

Subscribe to the onConversationUpdate event and register the callback by using the following sample manifest.json content.

manifest.json
"events": {
  "onConversationUpdate": {
    "handler": "onConversationUpdateCallback"
  }
}

Define the corresponding callback by using the following sample server.js content:

server.js
exports = {
  onConversationUpdateCallback: function(payload) {
    console.log("Logging arguments from onConversationUpdate event: " + JSON.stringify(payload));
  }
}

Attributes of the data object

  • actorobject

    Details of the entity that triggered the onConversationUpdate event.

  • associationsobject

    All associated objects of the conversation object, which specify additional information pertaining to the conversation updated.

  • changesobject

    Changes that triggered the onConversationUpdate event, specified as a JSON object of the following format:

    {
      "model_changes": {
        //For non-array attributes
        "<conversation.attribute that changed>": ["Old value", "New value"],
      }
    }

    Example

    "changes": {
      "misc_changes": null,
      "model_changes": {
        "assigned_agent_id": [
          "2823233e-7122-4f87-9d56-38aaaaeb676a",
          null
        ],
        "assigned_group_id": [
          "40753ac3-1f66-40d9-b903-23db0a9a70b0",
          null
        ],
        "status": [
          "new",
          "resolved"
        ]
      },
      "system_changes": null
    },
  • conversationobject

    Details of the conversation object created when the onConversationCreate event is triggered.