function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Krasimir KirilovKrasimir Kirilov 

Is is possible to pass original request header value to Einstein bot apex action?

Is is possible to pass original request header value to Einstein bot apex action?
SwethaSwetha (Salesforce Developers) 
HI Krasimir, 
I have reviewed salesforce documentation and public articles/examples but there is nothing specified regarding the way of passing request headers via apex action.
Reference: https://developer.salesforce.com/docs/atlas.en-us.bot_cookbook.meta/bot_cookbook/bot_cookbook_call_apex_action.htm

Thanks
SwethaSwetha (Salesforce Developers) 
HI Krasimir,
Can you give an example of a header you'd like to pass through and where does the header originate?
Krasimir KirilovKrasimir Kirilov
Hi Swetha. Cookie: chat-session=123;
SwethaSwetha (Salesforce Developers) 
HI Krasimir, Can you please elaborate on your usecase so I can suggest you better?
Krasimir KirilovKrasimir Kirilov
Hi Swetha.

I'm trying to build a chatbot for authenticated users. For the puprose i will like to serve the chatbot under my domain(I've already asked such question). And also when served from my domain, the customer will be able to pass the browser cookies when start the chat. Later i would liek to use some of the cookies to query my backend from salesforce. I'm wondering if such setup is possible at all. If not i'm very keen to understand how i can implement this. e.g. pass something secure to einstein to recognize the customer in my backend, that is currently chatting with the chatbot.

thanks,
Krasi
 
SwethaSwetha (Salesforce Developers) 
HI Krasi,
Got your point now! It's not possible to provide a custom header but for your use case I would recommend to create a custom field in the LiveChatTranscript or MessagingSession object (depending on the channel you are using) and populate this custom field using the pre-chat APIs. This field can later be read by the bot through a custom context variable that has a mapping to the custom field.
 
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
Krasimir KirilovKrasimir Kirilov
Hi Swetha, i'm aware of this option, however my cookies are httpOnly and this is the way i want them to be. I can't use them in the javascript.
 
SwethaSwetha (Salesforce Developers) 
HI Krasimir,
As currently there is no way to pass cookies in the header, please consider submitting your ask as an idea on Idea exchange so that the product team can implement it in coming releases based on number of upvotes. 
Link:https://success.salesforce.com/ideasearch 

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful.