-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(builtin): added removeVariable action (#11364)
* create removeVariable action * update tooltip docs
- Loading branch information
Showing
2 changed files
with
20 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Remove a variable from storage. | ||
* | ||
* @title Remove Variable | ||
* @category Storage | ||
* @author Botpress, Inc. | ||
* @param {string} type - Pick between: user, session, temp, bot | ||
* @param {string} name - The name of the variable | ||
*/ | ||
const removeVariable = async (type, name) => { | ||
if (type === 'bot') { | ||
const original = await bp.kvs.forBot(event.botId).get('global') | ||
await bp.kvs.forBot(event.botId).set('global', { ...original, [name]: 'null' }) | ||
} else { | ||
delete event.state[type][name] | ||
} | ||
} | ||
|
||
return removeVariable(args.type, args.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters