BotMan has a builtin storage system, which you can use to store user, "channel" or driver specific information without having the need for conversations. By default, BotMan will use a simple JSON file storage to keep the data in the filesystem.
The user storage is - as the name suggests - scoped to users. You can place user related information in there and also easily access stored elements for the current chatbot user, that you are interacting with:
$storage = $botman->userStorage();
The channel storage can be used to save and retrieve "channel" related information. This is especially useful in combination with messaging services that support the concept of "channels" - such as Slack channels or Telegram group chts.
$storage = $botman->channelStorage();
The driver storage is even more generic than the channel storage, as it is only restricted to the messaging service that is currently used. You can use this storage to store messaging service related information.
$storage = $botman->driverStorage();
You can write simple elements to the storage by using the
save method on your storage instance.
$bot->userStorage()->save([ 'name' => $name ]);
You can read elements from the storage in multiple ways.
all method will return all entries on the storage.
If you only want to select one specific entry / ID, you can use the
Once you have received an item from the storage, call the
get method to retrieve specific keys:
$userinformation = $bot->userStorage()->find($id); $element = $userinformation->get('my-custom-stored-element');
To delete existing entries from the storage, use the
delete method on the storage instance. This will delete
every information associated with the selected storage.