Skip to main contentIBM watsonx Assistant web chat

Salesforce

Integrating with Salesforce

Overview

Web chat comes with out-of-the-box support for communicating with a human agent using the Salesforce Chat APIs. Refer to the IBM watsonx Assistant Integrating with Salesforce documentation for enabling the integration with web chat.

The documentation provided here is specifically for the web chat APIs that can be used to provide advanced customizations of the integration.

Providing pre-chat details

Web chat allows you to provide additional details that can be sent to Salesforce when a chat starts. Specifically, web chat allows you to provide the values for the prechatDetails and prechatEntities properties as part of the ChasitorInit call.

To provide these values, use the agent:pre:startChat event. In that event, assign event.preStartChatPayload.preChat.details or event.preStartChatPayload.preChat.entities properties to the array of objects you wish to send to Salesforce.

Example
instance.on({
  type: 'agent:pre:startChat',
  handler: event => {
    event.preStartChatPayload = {
      preChat: {
        details: [
          {
            label: 'name',
            value: 'Customer Name',
            transcriptFields: ['name__c'],
            displayToAgent: true,
          },
        ],
        entities: [
          {
            entityName: 'LiveChatTranscript',
            showOnCreate: true,
            linkToEntityName: 'Case',
            linkToEntityField: 'CaseId',
            saveToTranscript: 'CaseId',
            entityFieldsMaps: [
              {
                fieldName: 'name__c',
                label: 'name',
              },
            ],
          },
        ],
      },
    };
  },
});

This information may also be provided by messages from IBM watsonx Assistant by setting the values in context under integrations.salesforce.pre_chat.Note that with the agent:pre:startChat event, the property is named preChat but in context, the property is named pre_chat.

Example
{
  "output": {
    "generic": [
      {
        "response_type": "connect_to_agent",
        "transfer_info": {
          "target": {}
        },
        "agent_available": {
          "message": "Yes! We're ready to help. Just ask."
        },
        "agent_unavailable": {
          "message": "Sorry! We're not available."
        },
        "message_to_human_agent": "Help this super-customer!"
      }
    ]
  },
  "context": {
    "integrations": {
      "salesforce": {
        "pre_chat": {
          "details": [
            {
              "label": "name",
              "value": "Customer Name",
              "transcriptFields": ["name__c"],
              "displayToAgent": true
            }
          ],
          "entities": [
            {
              "entityName": "LiveChatTranscript",
              "showOnCreate": "",
              "linkToEntityName": "Case",
              "linkToEntityField": "CaseId",
              "saveToTranscript": "CaseId",
              "entityFieldsMaps": [
                {
                  "fieldName": "name__c",
                  "label": "name"
                }
              ]
            }
          ]
        }
      }
    }
  }
}

Routing info

By default, web chat will use the routing info from the button and deployment code that is provided in the web chat live agent settings. That info may be overridden in messages returned from IBM watsonx Assistant if a specific agent request should be routed to a different agent or org.

To provide this info, use the JSON editor on a message in IBM watsonx Assistant and set the transfer_info.target.salesforce.additional_routing_info property to the alternate routing info you wish to use for that message. The additional_routing_info property is an array of RoutingInfo objects. Web chat will try to connect the user to an agent using the first info in that array. If that fails either because no agents are available or because all the agents decline or go offline, web chat will then move to the next info in the array.

Each RoutingInfo object contains the following properties. All of these properties are optional. If the value for any property is not included, web chat will fall back to the appropriate value from the web chat settings.

Property Type Description
button_id String The button ID to route to. If this value is not provided, web chat will look for a routing override in the message that may be set in the settings for the action or dialog node.
button_overrides Array (of Strings) The value for buttonOverrides to pass to Salesforce. See the Salesforce ChasitorInit docs for more information.
org_id String The ID of the org to connect to.
deployment_id String The ID of the deployment to connect to.
deployment_url String The hostname of the Salesforce server to connect to. Example: d.la4-c2-ia2.salesforceliveagent.com.
Example
{
  "output": {
    "generic": [
      {
        "response_type": "connect_to_agent",
        "transfer_info": {
          "target": {
            "salesforce": {
              "button_id": "your default button id",
              "additional_routing_info": [
                {
                  "org_id": "an org id",
                  "button_id": "a button id",
                  "button_overrides": [
                    "an additional button id"
                  ],
                  "deployment_id": "a deployment id",
                  "deployment_url": "a deployment hostname"
                }
              ]
            }
          }
        },
        "agent_available": {
          "message": "Yes! We're ready to help. Just ask."
        },
        "agent_unavailable": {
          "message": "Sorry! We're not available."
        },
        "message_to_human_agent": "Help this super-customer!"
      }
    ]
  }
}