Trigger an intent from the backend with Botfront

Hi @stephens, I hope you can help with this. I am using botfront to deploy my chatbot. Is there a way to send an intent from the backend via socket.io so that a conversation flow gets triggered and appears on the widget (simulating a user sending message without actually interacting with the botfront widget). I require this because I have different forms that need to be sent out to users on different days and times to record their medication intake.

For example, form A is triggered by intent A at 8pm. When the user access the bot at 9pm they will see the first question of form A and answer it accordingly.

Please if you can offer some assistance with this.

Thank you!

I have different forms that need to be sent out to users on different days and times to record their medication intake.

Rasa is not designed for this. You should find a different mechanism to notify the user and push them into a conversation with the bot. Maybe SMS, email, mobile app notification.

When the user access the bot at 9pm they will see the first question of form A and answer it accordingly.

For this, I would use action_session_start which is documented here. This is automatically called when the user starts a new session and you can kick off a form that checks for any messages that need to be sent or actions/forms that should be started.

@stephens thanks for the response, some followup questions.

Rasa is not designed for this. You should find a different mechanism to notify the user and push them into a conversation with the bot. Maybe SMS, email, mobile app notification.

For example if I send an SMS to the user telling them to log in. Once they are logged in to the portal and have the widget opened, then I have to somehow design a conversation flow where the user has to prompt the form? Is this what you are saying?

For this, I would use action_session_start which is documented here. This is automatically called when the user starts a new session and you can kick off a form that checks for any messages that need to be sent or actions/forms that should be started.

The issue is I have multiple different forms with different questions. Is it possible to use this function then?

For example if I send an SMS to the user telling them to log in. Once they are logged in to the portal and have the widget opened, then I have to somehow design a conversation flow where the user has to prompt the form? Is this what you are saying?

Yes

The issue is I have multiple different forms with different questions. Is it possible to use this function then?

Yes

@stephens sorry one last question, how do i force a form to start upon in the action_session_start function? Would it be something like this where we use the ActionExecuted or should it be the FollowUpAction?


class ActionSessionStart(Action):
    def name(self) -> Text:
        return "action_session_start"

    async def run(
      self, dispatcher, tracker: Tracker, domain: Dict[Text, Any]
    ) -> List[Dict[Text, Any]]:

        # the session should begin with a `session_started` event
        events = [SessionStarted()]

        # force form A to run when Session has started 
        events.append(ActionExecuted("start_formA"))

        # an `action_listen` should be added at the end as a user message follows
        events.append(ActionExecuted("action_listen"))

        return events

If this is incorrect, can you please let me know which function I should use?

Thank you in advance.

It’s best to do this with a slot like described here but you can also use FollowUpAction as described here.

1 Like

@stephens thank you, i’ll give these option and try. Hopefully that will resolve my issues.