Start your system's automation from the guide
To let agents start a process in your system, such as a return, a refund or an escalation, build a flow module that calls the operation of your system's target that starts it. The agent then runs the module from the guide, and the module returns your system's answer. With Salesforce, choose the operation from the table in Update records and run automation in your system; each runs as the integration user. The account and case guide that the stack creates has no button for your module: you call it from a copy of the guide flow, as Customize the guide describes.
The example in these steps is an Initiate return action, which uses
runFlow: an autolaunched flow, Initiate_Return, that
takes the case, a reason and a refund amount, records the return request, and
returns a code that says what happened. The module acts on the case in the calling contact's caseId attribute; for which case that is, see The case view. Call the module from your copy of the
guide flow, where it acts on the last case the agent opened, or from agent assist,
where it acts on the case open in the guide.
To prepare the flow in Salesforce
-
Create the autolaunched flow
Initiate_Return, with these Text variables available for input:caseId,reason,refundAmountandcomments. Add a Text variable available for output,outcome, and set it to a code such ascreated,invalidornoCase. Check the inputs in the flow itself, and check whether the return already exists, because Connect Customer can run a failed call again. -
Activate the flow.
-
Make sure the integration user has the Run Flows permission and access to the objects the flow uses. The setup script in Create the integration user and its access grants Run Flows when
runFlowsistrue, the default.
To build the Initiate return module in Connect Customer
-
Create a flow module named, for example,
Initiate return, with the inputsreason,refundAmountandcomments, the output fieldoutcome, and the branches Ran, Refused and Failed. Write its description for the agent, such asStarts a return on the open case. reason is Damaged, WrongItem, NotAsDescribed or NoLongerNeeded, and use the same text as the tool's description when you add the module to an AI agent. -
Add a Check contact attributes block on
$.Attributes.caseId. The block takes the first condition that matches, so list the conditions in the order the stack's modules use: first one Contains condition for each refused character,' \ % & # ? / +, each going to a Return block with the branch Refused; then, last, a condition that the value starts with500, which continues to the next block. Send No match to the Refused Return block too. Check thatreasonis one of the values the flow accepts (the sample takesDamaged,WrongItem,NotAsDescribedorNoLongerNeeded), and thatrefundAmountandcommentshold no'or\. Send any value that fails to a Return block with the branch Refused. -
Add an External Tool block. For the application, choose the stack's integration,
Salesforce -, and for the toolstack-namegateway_. Set its three inputs:gateway-id__salesforce___runFlowdomainNameto your org's My Domain name, the part of its host before the first dot;flowApiNametoInitiate_Return; andbodyto the flow's input variables:{"inputs": [{"caseId": "$.Attributes.caseId", "reason": "$.Modules.Input.reason", "refundAmount": "$.Modules.Input.refundAmount", "comments": "$.Modules.Input.comments"}]} -
On the block's success branch, add a Return block with the branch Ran, and set
outcometo the flow's output:`$.ExternalTool.ResultData[0].outputValues.outcome`, with the backticks. On its error branch, add a Return block with the branch Failed. -
Publish the module, and create a version and an alias.
-
Run it from your copy of the guide flow with an Invoke flow module block, as in Extend the guide with flow modules.
In your copy of the guide flow, show a view after the module, with a line for
each outcome code, such as "Return created."
Errors come back in two ways. If the gateway or Salesforce refuses the call, for
example because the flow isn't active or autolaunched, an input name is wrong or the
integration user lacks Run Flows, the
External Tool block takes its error branch and the module
returns Failed; see Flows. If the flow runs
but can't do the work, it says so in outcome, so compare that value
before you tell the agent the return was created.
The other operations in the table work the same way, with their own inputs.
The gateway's runFlow tool runs any active autolaunched flow the
integration user can run, so the integration user's access, which your Salesforce
administrator sets, decides which flows the gateway can start.