Support for external triggers / asynchronous actions
See original GitHub issueMotivation
There is currently no way to send a bot message to the user via an external API call. This is e.g. useful
- if an external sensor should trigger sth like an alert, which should result in a message to the user
- if you have asynchronous action which should notify the user when they are finished.
Proposed Solution
When calling this endpoint (/conversations/{conversation_id}/execute
) it should be possible to specify an output channel (either by name or latest
) which the output of the action should be redirected to.
Now there are two cases of channels:
- asynchronous ones (were we send a message to an endpoint (e.g. facebook) and they take care of getting it to the user)
- synchronous ones (e.g. Rest), where the user usually sends a message and waits for the result. We have no way to directly contact the user, we have to wait until the user comes back
Asynchronous Channels:
In case of asynchronous channels we can create the input channel based on the credentials files (from_credentials
) and call send_message
(we have to make sure each asynchronous channel has such a method).
Maybe sth like:
channel_from_query = ...
channel = _create_single_channel(channel_from_query, credentials)
output = channel.get_output_channel()
if not output:
# channel not supported since it's synchronous
else:
output.send_response(...)
Synchronous Channels:
The question is how to handle synchronous channels. Either
- don’t support this functionality for them (easier, but not solved in a clean way imho)
- store the bot messages with a flag “not retrieved” in the database (I think
bot
events are not featurized, right?) and look for “not retrieved” messages the next time the user comes back, and send these together with the results of the next call - have some sort of global in-memory buffer of the format
Dict[sender_id, List[BotMessages]]
whereby we have to ensure that a certain size of this buffer is not exceeded
I opt for not supporting synchronous channels, but giving the option to provide a webhook in credentials.yml
which can be called.
Webhook in credentials.yml
Guess we could implement this as regular channel, which can only be used as output channel?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:14 (11 by maintainers)
Top GitHub Comments
@tabergma Please check if that’s somewhat understandable:
No. So you have three participants
user
chatting to the botbot
trigger
): this could e.g. be a sensor, some event (“your pizza is ready now”)Currently it’s not possible to model the following case:
user
speaks to thebot
(E.g. ordering a pizza)trigger
) calls an action on the current conversation of theuser
by doing an HTTP request to the Rasa API). This action leads to someBotUtterance
events which should be communicated back to the user (e.g. “Pizza is ready”)The intent-trigger-issue is here: https://github.com/RasaHQ/rasa/issues/4464