createSession (JavaScript API Reference) for Dynamics 365 Channel Integration Framework 2.0

Note

This content applies only to Dynamics 365 Channel Integration Framework version 2.0.

Note

Session management APIs allow you to integrate multisession experiences only in Omnichannel for Customer Service app.

Creates a new session based on the session template name and returns the unique identifier of the session that was created. This method supports session templates of type Generic.

Syntax

Microsoft.CIFramework.createSession(input, correlationId).then(successCallback, errorCallback);

Parameters

Name Type Required Description
input String Yes JSON string
correlationId GUID No Used to group all related API calls together for diagnostic telemetry.
successCallback Function No A function to call when the request is successful. The input to this function is the unique identifier of the newly created session.
errorCallback Function No A function to call when the request fails

The structure of the input parameter JSON is as follows:

{ 
   "templateName":"<unique name of session template>",
   "templateParameters":{ 
      "globalparam":"number value OR boolean value OR json string value OR parameterized string value",
      "app template 1":{ 
         "param 1":"number value OR boolean value OR json string value OR parameterized string value",
         "param 2":"..."
      },
      "app template 2":"…."
   }
}

Return value

Promise with a value as String.

Example

var input = {
   // unique name of the configured template   
    templateName: "msdyn_chat_session",
 
    templateParameters: {
        customer: "Contoso",
    }
    // Global and application tab template parameters, these values will override configured values
   };
Microsoft.CIFramework.createSession(input).then(function success(sessionId) {
    console.log(sessionId);
    // perform operations on session Id retrieved
}, function(error) {
    console.log(error.message);
    // handle error conditions
});