You need to sign in to do that
Don't have an account?
Julia Krause
Is there any solution?
Thanks,
Julia
How to pass URI Param to LiveChatTranscript by a customize PreChat Component?
Hello,
I use a Einstein Bot inside Salesforce Community.
The goal is: The Bot have to provide informations about a specify Order. The order Id is passed by a url parameter.
In the moment: The PreChat Component recognizes the param and represents it to the user. But how can I store this id to a custom field inside the LiveChatTranscript record to use it inside the Bot?
As a basis, I used the code from this side: https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_lightning_components_prechat_sample_aura.htm
Component:
<aura:component implements="lightningsnapin:prechatUI" description="Sample custom prechat component for Snapins. Implemented using Aura." controller="EinsteinBot_SaveRecordeController"> <!-- Source: https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_lightning_components_prechat_sample_aura.htm --> <!-- You must implement "lightningsnapin:prechatUI" for this component to appear in the "Prechat Component" customization dropdown in the Snapins setup. --> <!-- Prechat field components to render. --> <aura:attribute name="prechatFieldComponents" type="List" description="An array of objects representing the prechat fields specified in prechat setup."/> <!-- get url parameter --> <aura:attribute name="isOrderParamInsideURI" type="Boolean"/> <aura:attribute name="orderIdLabel" type="String"/> <aura:attribute name="orderIdValue" type="String"/> <!-- Handler for when this component is initialized. --> <aura:handler name="init" value="{!this}" action="{!c.onInit}" /> <!-- For Aura performance. --> <aura:locator target="startButton" description="Prechat form submit button."/> <!-- Contains methods for getting prechat fields, starting a chat, and validating fields. --> <lightningsnapin:prechatAPI aura:id="prechatAPI"/> <h2>Prechat form.</h2> <div class="prechatUI"> <div class="prechatContent"> <ul class="fieldsList"> <!-- Look in the controller's onInit function. This component dynamically creates the prechat field components. --> {!v.prechatFieldComponents} </ul> <aura:if isTrue="{!v.isOrderParamInsideURI}"> <p> more information About the Order: </p> <p> {!v.orderIdValue} </p> </aura:if> </div> <div class="startButtonWrapper"> <ui:button aura:id="startButton" class="startButton" label="{!$Label.LiveAgentPrechat.StartChat}" press="{!c.handleStartButtonClick}"/> </div> </div> </aura:component>Helper:
... /** * get order Id out of uri * TAKE CARE: static implementation for a Demo version */ getOrderIdFromURI: function(cmp, evt, hlp) { var isParamInsideURI = false; var orderParam = decodeURIComponent(window.location.search.substring(1)); var orderParamParts = orderParam.split('='); if(orderParamParts.length == 2){ var orderParamLabel = orderParamParts[0]; var orderParamValue = orderParamParts[1]; isParamInsideURI = true; //set attributes cmp.set('v.orderIdLabel', orderParamLabel); cmp.set('v.orderIdValue', orderParamValue); } return isParamInsideURI; } ...
Is there any solution?
Thanks,
Julia