Create a Sample Einstein Bot

To help your customers efficiently set up an Einstein Bot with Bring Your Own Channel for CCaaS, create a sample Einstein Bot and associated Omni-Channel Flows and include them in your managed package.

In this example, we create an outbound Omni-Channnel Flow that routes from a bot to an agent. We then set up a sample Einstein Bot that uses this outbound flow and automatically generates a corresponding inbound flow that sends conversations to the bot. For your package, we recommend creating a flow and bot configuration that reflects the expected business logic of your customers.

Follow steps in Salesforce Help to create an Omni-Channel flow to Route Work Items to a Specific Agent. This sample outbound flow transfers the Messaging end user from an Einstein Bot to an agent.

You need this flow to select it as the Outbound Omni-Channel Flow during Einstein Bot setup.

  1. From Setup, in the Quick Find box, enter Einstein Bots, and then select Einstein Bots.
  2. Enable Einstein Bots if it’s not already enabled.
  3. Launch the guided setup from the Einstein Bots main page. For your first bot, click Create a New Bot. Otherwise, click New.
  4. Select Enhanced Bot, and then click Next.
  5. To create an Einstein bot from scratch, select Start from Scratch, and then click Next.
  6. Personalize your sample bot.
    • Enter a bot name, select a primary language, and then click Next.
    • Modify the welcome message, but don’t customize the menu items. Your customers adjust them when they clone your sample Einstein Bot. When you’re done, click Next.
  7. On the Link to deployment page of the guided setup, select Create an inbound Omni-Channel flow for my bot, and then from Outbound Omni-Channel Flow dropdown, select the flow that you created.
  8. Click Proceed to start the bot creation process, and then click Finish to confirm when it’s done.

When the system has finished creating the bot, Einstein Bot Builder opens.

Configure the Einstein Bot to trigger the sample flow that transfers a Messaging session from the bot to an agent.

  1. If you aren’t already in Einstein Bot Builder, from Setup, enter Einstein Bots in the Quick Find box, and then select Einstein Bots. In the My Bots section, select the name of the bot that you created.
  2. In Einstein Bot Builder, from the Bot Builder menu, click Dialogs.
  3. In the Dialogs panel, click New.
  4. Give the dialog a name, such as Get help from an agent. Enter an API name and optional description, and save.
  5. In the Dialogs panel, select the newly created dialog.
  6. Click Next Step. From the Step Properties panel, select Transfer to an agent. Dialog with Transfer to an agent selected as Next Step
  7. Save the dialog.
  8. In the Dialogs panel, select Main Menu.
  9. Click Next Step. From the Step Properties panel, select Show a menu and add the Get help from an agent dialog you created previously as one of the menu items. Main Menu Dialog with Get help from an agent included as a menu item
  10. Save your work.

When you create the managed package for your integration, add these components to the managed package.

  • The sample Einstein Bot that you created
  • The sample Omni-Channel outbound flow that you created
  • The inbound Omni-Channel flow that the system automatically created

If routingOwner is Partner in the Conversation Channel Definition record, partners handle routing for the messaging session to and from the Einstein Bot. If routingOwner is Salesforce, partners don’t need to handle routing to or from the Einsten Bot. Salesforce handles this automatically.

Perform the API calls in the order listed to handle routing for the inbound Omni-Channel flow that connects a messaging end user to an Einstein Bot.

  • Call the Interaction API (POST /api/v1/interactions) to create a conversation messaging session and a messagingEndUser record. This API execution returns a conversationIdentifier value used in the next step.
  • Call the Route API (POST /api/v1/route) with routingType set to initial and conversationIdentifier set to the conversationIdentifier value returned from the previous step. This executes the inbound Omni-Channel flow that’s associated with the messaging channel.
    • In the Route API payload, pass in the ID of flowDefinitionViewfor the flowId field. For the queueId field, pass in the ID of fallbackQueue. The customer provides these values.
    • The Route API response includes the salesforceBotId and psrId.

The Einstein Bot is added to the conversation and sends a welcome message to the end user.

Perform the API calls in the order listed to handle routing for the outbound Omni-Channel flow that transfers a messaging end user from an Einstein Bot to an agent.

  • A routing request event provides the flow ID of the outbound Omni-Channel flow. The flow can be customer-configured.
  • Call the Route API (POST /api/v1/route) with routingType set to transfer to execute the flow ID provided by the routing request event. Alternatively, transfer to the fallbackQueueId if the transfer to the outbound Omni-Channel flow fails.
  • The Omni-Channel flow uses the logic in the flow to route the conversation to a rep or queue. The flow returns the psrId with the userId (agent) or queueId (queue).
  • Call the agentWork API (POST /api/v1/agentWork) to create an AgentWork record when the system finds a potential rep or queue to handle the work item.
  • After routing completes, call the routingResult API (POST /api/v1/routingResult) to notify Salesforce whether the conversation succeeded or failed.

See Also