0

In Botpress I want to store the authKey and Expiry in that and call for each iteration when ever the key expires it should call again the function and store it.

btw there is no refresh key, the API provides only key and expiry

There is very limited material on this could any of you worked or know about this it would be helpful.

https://botpress.com/reference/modules/_botpress_sdk_.kvs.html

Sai
  • 91
  • 1
  • 11

1 Answers1

1

hey you can do something like

await bp.kvs.forBot(botId).set(key, value, undefined, "expiry in milliseconds");

then

await bp.kvs.forBot(botId).get(key)
Dharman
  • 30,962
  • 25
  • 85
  • 135
joe az
  • 36
  • 2
  • Thank you Joe az , Its working and another question is In Node Js How to store the the key from api and return the token without calling the api again and call only when it expires and store it. – Sai Mar 04 '22 at 13:33
  • you can use the kvs for that, when you get the token just use the above code and when you want to retrieve, use the bottom code – joe az Mar 08 '22 at 15:38
  • Hi Joe, I tried with get and set methods in kvs but its not working as needed.. if possible could you pls provide with example? – Sai Mar 09 '22 at 10:07