question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for external triggers / asynchronous actions

See original GitHub issue

Motivation

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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
wochingecommented, Jul 8, 2019

@tabergma Please check if that’s somewhat understandable:

So, the user is calling an endpoint and expects an actual bot response either via the api response or via a specific channel (which the user can specify in his request). Is that correct? Are external triggers then also calling this API? Maybe you can explain again

No. So you have three participants

  • a user chatting to the bot
  • the bot
  • some external event (let’s call it 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:

  1. user speaks to the bot (E.g. ordering a pizza)
  2. [something going on in between] (e.g. the user closes their app)
  3. An external event (trigger) calls an action on the current conversation of the user by doing an HTTP request to the Rasa API). This action leads to some BotUtterance events which should be communicated back to the user (e.g. “Pizza is ready”)
1reaction
JEM-Mosigcommented, Oct 21, 2019

The intent-trigger-issue is here: https://github.com/RasaHQ/rasa/issues/4464

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling external events in Durable Functions - Azure
External events are one-way asynchronous operations. They are not suitable for situations where the client sending the event needs a synchronous ...
Read more >
Using asynchronous actions in a Flow - Gradient Works
Step 1 is to create a Record-Triggered Flow based on the User object, with these options in the Start action: Trigger when “A...
Read more >
Explore Flows and Triggers - Auth0
Some Triggers are executed synchronously, blocking the flow in which they are involved, and some are executed asynchronously.
Read more >
Asynchronous actions with AWS Step Functions
Let's build a scalable solution which helps us track the current state of an execution and handles external asynchronous actions triggered ...
Read more >
Deferrable Operators & Triggers - Apache Airflow
Triggers are small, asynchronous pieces of Python code designed to be run all together in a single Python process; because they are asynchronous,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found