Prefill slots via rest channel

Hi,

I am setting up rasa for our app, and one of the requirements is, to be able to pass in slots. The intent here is when sending a user input to rasa, we already have some basic information about the user that we can then use in the story. Basic example: we already know the user’s name, so we can skip the part of the story that needs to ask for user’s name.

The rest API seems to only be allowing us to send the message content, and not the slots.

Can someone who might have achieved the same previously, shed some light on their approach?

Welcome to the forum :slight_smile:

If I understand correctly, you want to pass information from Rasa to your app?

As you can send messages, images, and buttons, you can also send custom payloads.

In custom actions, you can do so with dispatcher.utter_message(attachment = json_data).

Thank you for the welcome!

I was trying to not have to make custom actions for this. But if there is no other way, then i’ll use custom actions itself.

1 Like

No need to use custom actions, I think you can make it work with custom payloads.

If you put the slot between curly brackets it may work (never tried it for things other than text):

responses:
  utter_sending_slots:
  - text: "I'm sending the slots over!"
  - custom:
      slotvalues:
      - name: "{name}"
        age: "{age}"

Hey Chris!

Yeah, responses are working for me. But I want to find out how to send over the values to rasa, not get them back.

Here’s the flow I have.

A customer is sending us a message, we extract the customer’s information and send the message to rasa. I don’t know how to pass on the customer information to rasa along with the message, so currently rasa is responding back with no knowledge of who or what the customer is/needs.

Please read about Custom Connectors.

What you can also do is a background script that secretly sends a payload whenever the user opens the app.

For example: /greet{"name": user.name, "age": user.age}

the /greet is a “regex” message?

/greet is the way to force Rasa to recognize this user message as Intent - greet with 2 entities attached name, age. You can replace the Intent and attached Entities with whatever you like. You can check this section BYPASS NLU WITH BUTTONS for more information

1 Like

It’s a payload to force the bot to parse a message with intent greet and entities name and age.

Is there an example I can refer to? Our attempts at using this seems to be failing.

You literally send this as you would for a normal message.

In your frontend, instead of

send('Hello, my name is Chris and I am 23 years old')

you do

send('/greet{"name": "Chris", "age": "23"}')

Hi Chris!

Thank you! Was finally able to get this to work!

1 Like

Glad to hear it :slight_smile: Please mark the answer as solution to display the thread as solved

1 Like