Cookie implementation chatbot

I want to use cookie in my bot so that each time a new user enter it will greet him with a fresh message and if a user has already visited the bot, it can recognize the user and greet him with a different message…it that case I wanna implement cookie to store username and use the cookie to retrieve the stored data and display it

Sorry if it didn’t answer your question. But botpress have a build-it memory. Probably the sessions variable will have the same behaviour as a cookie :thinking:. Cookie have a limited time.

Session

function action(bp: typeof sdk, event: sdk.IO.IncomingEvent, args: any, { user, temp, session } = event.state) {
  /** Your code starts below */


  const greetingMessage = [
    'Holla friend',
    'Hello Folks',
    'Salut !'
  ]

  const myAction = async () => {
    try {
      if (session.slots.userName) {
        temp.user_name = session.slots.userName.value
        const payloads = await bp.cms.renderElement(‘builtin_text’,  { text: _.random(greetingMessage.length-1)] }, event);
        await bp.events.replyToEvent(event, payloads);       
      } else {
        temp.name_given = false
        const payloads = await bp.cms.renderElement(‘builtin_text’,  { text: `I don't know you` }, event);
        await bp.events.replyToEvent(event, payloads);   
      }
    } catch (e) {
      // do something with error
    }
  }

  return myAction()

The duration value of the sessions variable can be modified