Call to rasa action server are not reflected in Rasa server

Hi, I am trying to start a conversation by making a call to the rasa action server and passing in some data to set some slots.

I create a unique sender_id which I pass to the api calls to both the Action and open source server.

However, when I fetch the story of the conversation with the conversations/{conversation_id}/story endpoint, the slots are not set and the action call does not show up in the story.

It seems like the calls to the Rasa action server are not impacting the conversation with the open source server even though the sender_id is being passed to the action server.

Is this the expected behavior that action server api calls with the same sender_id do not affect the conversation being had with the open source server with the same sender_id?

Hi, I am trying to start a conversation by making a call to the rasa action server and passing in some data to set some slots.

You should be using action_session_start for this. Discussed here.

which I pass to the api calls to both the Action and open source server

You shouldn’t be call the action server directly. Actions should be invoked in the course of stories or rules.

However, when I fetch the story of the conversation with the conversations/{conversation_id}/story endpoint, the slots are not set and the action call does not show up in the story.

If you want to access slots, you should do that in your custom actions via the tracker.get_slot method.

@stephens I may not have articulated my problem correctly.

Here is some context, I want to be able to send a text message message to a user to schedule an appointment with them.

I want to be able to start a new conversation with the rasa server by triggering a custom action (seems like this should be action_session_start) and also pass data with that action call to personalize the conversation. For example, passing the customer name and scheduling options that they could select from.

I tried starting a conversation by making a call to the action server with action_session_start and passing the following data:

{
      next_action: 'action_session_start',
      tracker: {
        sender_id: sender_id,
        slots: {
            "customer_name": "Raj",
            "appointment_options": ["Thursday at 10am", "Thursday at 11am"]
        }
      },
    }

The conversation seems like it goes well, but when fetching the tracker and story after the conversation is over, the response are missing data. The story is missing the action_session_start and the tracker has none of the slots set.

Here is my custom action_session_start action:

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]]:
        metadata = tracker.get_slot("session_started_metadata")

        # Do something with the metadata
        print(metadata)

        customer_name = tracker.slots["customer_name"]
        appointment_option_1 = tracker.slots["appointment_options"][0]
        appointment_option_2 = tracker.slots["appointment_options"][1]

        dispatcher.utter_message(text=f"Hi {customer_name}, which appointment works for you? Can I suggest the {appointment_option_1} or {appointment_option_2} instead?")

        # the session should begin with a `session_started` event and an `action_listen`
        # as a user message follows
        return [SlotSet("customer_name", tracker.slots["customer_name"]), SessionStarted(), ActionExecuted("action_listen")]

Here is the fetched story:

version: "3.1"
stories:
- story: 59d7af14-8c8b-46f6-b32d-95be3a55b45a
  steps:
  - intent: user_selected_appointment
    user: |-
      [Thursday at 10am](appointment)
  - action: utter_appointment_selection_confirmed

Slots from the tracker:

"slots": {
        "customer_name": null,
        "appointment_options": null,
        "session_started_metadata": null
    },

In the events on the tracker I do see the session_start and action_listen event, but the slots are not being set.

Any help as to why the slots are not being set on the tracker and as to why the action is not showing up in the story would be greatly appreciated!

I’m not sure if this approach with action_session_start is going to work. I would look at the source code around this. I assume the conversation with the user is all done via SMS. I wonder what system you use to trigger the appointment and SMS but I would do all of this outside of Rasa (not part of the action server). I would send the SMS to start the conversation out side of the action code so that the users response is the first thing that Rasa sees and the action_session_start is invoked in the normal way.

I also wonder about your session_id’s. Are they really the same between sessions?

You may also be better off storing user data in a db between sessions.

@stephens, ah I see okay. I’ll try to poke around. I use the same sender_id to both the action server and rasa server so I would assume that the sessions are the same.

Few follow up questions.

  1. If we send the first message outside of the rasa server, will this have a significant impact on the stories? Since the first message can vary based on the number of appointments that we are trying to schedule and the number of appointment options we have. In some cases, we may want to schedule two appointments in the conversation.

  2. If we send the first message outside of rasa, how would we be able to set slots in the conversation? It seemed like those would have been set in this first action.

  3. I also had an idea of using the append event to tracker endpoint to attach the response of the action_session_start action to the conversation tracker. But appending events to the tracker also didn’t seem to set the slots on the conversation tracker.

These are the events I passed into the append event to tracker endpoint. But when i fetch the conversation tracker using this endpoint, the customer_name slot is null. I checked that I am using the same conversation_id in both calls.

[
    {
        "event": "slot",
        "name": "customer_name",
        "value": "Raj"
    },
    {
        "event": "session_started"
    },
    {
        "event": "action",
        "name": "action_listen",
        "policy": null,
        "confidence": null
    }
]

Main question at this point, is how do I get the slots set so that they can be used in the conversations.

Really appreciate your help so far!