Botfront webchat - how to get cookies from user?

Hey guys, as I didn’t know where to look, I’m interested of achieving the following using rasa:

  • A user logs in on my WP website
  • The user opens the chat to talk to the bot (Botfront’s webchat)
  • I get the WP_cookie of the user so that I can check in the backend the details of the user to offer specific help based on account details.
  • So far I have no idea how to do that, I would be thankful for any resource that could help me find a way to.

Looking forward for any answers


This is very similar to the answer I gave here: Different response for each users types - #6 by ChrisRahme

Hello, thanks for the answer, I will check it out. Thing is I am not the creator of the web app and I am not sure how to implement this with botfront. Only thing I can do is adding scripts in either body/head/footer. That would be an option to run some code. But not sure how to actually send that through botfront to rasa.

Hello George.

I guess this much depends on Wordpress Website and Admin. Let me give you a general idea.

As users log in (visit your company website), and click the widget, your website starts making a record.

As you are only using the botfront snippet code and paste it in the header and footer again it’s related to the WP.

Again, it’s related to WP as your website stores all the incoming traffic. If you are asking for some user details (as per GDPR compliance) then I would recommend using tracker stores for the same as cookies only stores related to website not regarding widget.

Can you further elaborate more on this

It is much related to the details you store using tracker store so that you can apply some analytics at the backend and then provide the solution.

I hope this will help you and I’d recommend discussing more on this with your website admin and what he is using for monitoring the traffic such as lead feeder, SEO, etc

Thanks, Nik

Yeah, you need to learn how to modify Botfront’s script.

I suggest using Chatbot Widget, the code is pure JavaScript and therefore a lot easier to understand and modify.

@ChrisRahme I understand, but, I only need the cookies the first time the user opens the chat. But I cannot set that initial payload to the cookie value of the user.

There must be a way to grab the cookies with wp and send them through the configuration script of botfront. Hopefully

There surely is, but I’ve never worked with either WordPress or Botfront

That is helpful indeed. I am trying to communicate with the admin, but he is not a reliable contact as he is not as experienced as he should’ve. I have never worked with Wordpress and that’s where I’m having issues.

So in order to move on, I should request the following from WP admin?

  • Method of authentication
  • How does he store and identify user roles

Then, with that info, I should find a way to send it from Wordpress to Rasa through the widget. I understand you can set custom slots with the initial payload, so it would be really useful to send the cookies as the initial payload and have the info from start :d

@georgebrianb Ok, did you ever work with cookies? did you know the format of the cookie and how much information cookies can store? I’m not sure why you emphasize more on cookies and you are using snipped code on WordPress so complexity is very hard ( I personally have not implemented such a use case ) but if you want to explore more please see this link: How to Set, Get, and Delete WordPress Cookies (like a Pro)

Note: I take no responsibility for any update of code or issue arising on your WordPress if you experiment with the given link. I am just helping you and giving you the idea - Thanks

I strongly recommend using the tracker store for storing the user information. Thanks -Nik

Cookies are usually set by the web server using the Set-Cookie header. The browser will then automatically add them to (almost) every request to the same domain using the Cookie header. You can also access cookies directly from the browser using the document.cookie property.