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.
- From Setup, in the Quick Find box, enter
Einstein Bots
, and then select Einstein Bots. - Enable Einstein Bots if it’s not already enabled.
- Launch the guided setup from the Einstein Bots main page. For your first bot, click Create a New Bot. Otherwise, click New.
- Select Enhanced Bot, and then click Next.
- To create an Einstein bot from scratch, select Start from Scratch, and then click Next.
- 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.
- 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.
- 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.
- 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. - In Einstein Bot Builder, from the Bot Builder menu, click Dialogs.
- In the Dialogs panel, click New.
- Give the dialog a name, such as
Get help from an agent
. Enter an API name and optional description, and save. - In the Dialogs panel, select the newly created dialog.
- Click Next Step. From the Step Properties panel, select Transfer to an agent.
- Save the dialog.
- In the Dialogs panel, select Main Menu.
- 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. - 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 aconversationIdentifier
value used in the next step. - Call the Route API (
POST /api/v1/route
) withroutingType
set toinitial
andconversationIdentifier
set to theconversationIdentifier
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
flowDefinitionView
for theflowId
field. For thequeueId
field, pass in the ID offallbackQueue
. The customer provides these values. - The Route API response includes the
salesforceBotId
andpsrId
.
- In the Route API payload, pass in the ID of
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
) withroutingType
set totransfer
to execute the flow ID provided by the routing request event. Alternatively, transfer to thefallbackQueueId
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 theuserId
(agent) orqueueId
(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
- Salesforce Help: Set Up an Einstein Bot for Bring Your Own Channel
- Salesforce Help: Route Conversations to and from Your Enhanced Bot
- Salesforce Help: Add a Dialog
- Salesforce Help: Set Up a Dialog
- GitHub: Interaction Service APIs