Is there a way to trigger a user intent (not an action) from the code or from the API?

Hi there!

We started making use of webviews in Facebook Messenger and have Call-to-Action buttons in some of our webviews (for example, a button to “Schedule a viewing”). When a user click on this button, we want the bot to behave as if the user had said something with the intent /schedule_viewing.

I understand we can use the HTTP API to trigger an action in Rasa which works fine. However, in this case, we would like to trigger an intent for which Rasa will predict the next action depending on the rest of the story.

Right now, we are able to insert user intents in the tracker and call specific actions from a custom endpoint. However, that means doing the story logic within this custom endpoint instead of relying on the stories to do so.

Therefore:

  1. Is there a way to trigger a user intent and let Rasa predict the next actions from the API?
  2. If not, can we force Rasa to predict the next actions through the code or API? (That way, we can just insert the intent in the tracker and force Rasa to predict the next steps)

Thanks a lot for your help! Cheers, Nicolas

Would using payloads and buttons calling the intents not work for this example?

@btotharye do you mean a button showing up in our bot messages? Our use-case is to embed a button within a Facebook Messenger webview (ie: the button will be displayed outside of the bot as Facebook displays an iframe in the webview).

What about just using the http://localhost:5005/model/parse with a {"text": "hello"} and do it that way and parse the intent from it maybe?

HTTP API has more information on it, maybe something like this or equiv API commands could work for your situation. Sorry I’m not as familiar with webview.

You can send the intent payload to the same webhook as a normal message:

e.g. to http://your-domain.com/webhooks/facebook/webhook, send

{
  "message": "/schedule_viewing", 
  "sender": "your sender's id, optional or UUID"
}
2 Likes

Thanks for your answer @erohmensing! In the webhook, there is a signature validation which checks the signature set in the X-Hub-Signature (which I assume Facebook Messenger sets). What should we put in there?

hmm that’s a good question i don’t know the answer to off the top of my head. I think there are two ways to debug + find out:

  1. use chrome developer tools to inspect the network requests that get sent when you send a regular message

  2. set up ngrok (temporarily) in front of your existing bot and redirect the webhook url to the ngrok server. ngrok provides a nice UI to be able to inspect requests that come in to the server

  3. add some debugging information in the facebook webhook in the rasa code to figure out what it is checking

Thanks!

A colleague of mine found that the value is the sha1 hash of the raw payload and app secret, it shouldn’t be hard to do that. https://developers.facebook.com/docs/messenger-platform/webhook/#security

Cheers, Nicolas

@nbeuchat Intent-triggering external events (and reminders) are released now! See Releases · RasaHQ/rasa · GitHub and Responses

Hi @j.mosig, that’s great, thanks for the heads-up! We got super excited to see it pops-up in the changelogs (I’m monitoring it not to miss any update!)

We’ll be trying it out in the next days, this should cleanup quite a bit of our hacks :slight_smile:

Best, Nicolas

1 Like