How to set slots when sending data from an API to the bot

We are trying to send entities with a payload like

{"sender": "12345", "message": "/greet{'language': 'en'}"}

but the entities/slots are not getting set. Can you please help us with the same.

Endpoint : https://127.0.0.1:8443/webhooks/rest/webhook

Error:

/opt/venv/lib/python3.8/site-packages/rasa/shared/utils/io.py:99: UserWarning: **Failed to parse arguments in line '/greet{'language': 'en'}'. Failed to decode parameters as a json object (dict).** Make sure the intent is followed by a proper json object (dict). Continuing without entities. Error: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
  More info at https://rasa.com/docs/rasa/stories

Domain.yml file:

version: "3.0"
config:
  store_entities_as_slots: true
intents:
  - greet
  - goodbye
  - affirm
  - deny
  - mood_great
  - mood_unhappy
  - bot_challenge
  - enter_intent
actions:
  - action_hello_world
  - action_extract_input_text
  - utter_cheer_up
  - action_get_faq
  - action_greet_message
  - action_check_agent
  - action_agent_transfer_confirm
  - action_perform_agent_transfer

entities:
  - language
  - country
  - account_number
  - survey

slots:
  language:
    type: text
    mappings:
    - type: custom

Stories.yml file: 

version: "3.0"

stories:

- story: FAQ Search + Don't need more help with FAQ
  steps:
  - intent: greet
  - action: utter_survey_affirm
  - intent: enter_intent
  - action: action_get_faq
  - intent: affirm
  - action: utter_survey_affirm

JSON requires double quotes. Try this:

{"sender": "12345", "message": "/greet{\"language\": \"en\"}"}

Thanks. I have update it and also had to update the slot mapping to “from_enity”. Thanks !!!

1 Like