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 location 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. Setting additional_routing_info will override button_id.

If you provide multiple IDs, web chat will check each one in order to determine if any agents are available and will connect the user to the first available.

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_ids": [
                    "an additional button id"
                  ],
                  "deployment_id": "a deployment id",
                  "deployment_url": "a deployment url"
                }
              ]
            }
          }
        },
        "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!"
      }
    ]
  }
}