Skip to content

Commit

Permalink
Merge pull request #7972 from RasaHQ/external-message-autofill-fix-2-X
Browse files Browse the repository at this point in the history
External Message Entity Auto-Filling Fix
  • Loading branch information
b-quachtran authored Feb 22, 2021
2 parents b75b1ee + 4b9830e commit 3f054c3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/7972.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug where, if a user injects an intent using the HTTP API, slot auto-filling is not performed on the entities provided.
3 changes: 2 additions & 1 deletion rasa/core/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,8 @@ async def trigger_external_user_uttered(
input_channel = tracker.get_latest_input_channel()

tracker.update(
UserUttered.create_external(intent_name, entity_list, input_channel)
UserUttered.create_external(intent_name, entity_list, input_channel),
self.domain,
)
await self._predict_and_execute_next_action(output_channel, tracker)
# save tracker state to continue conversation from this state
Expand Down
23 changes: 23 additions & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,29 @@ async def test_trigger_intent(rasa_app: SanicASGITestClient):
assert parsed_content["messages"]


async def test_trigger_intent_with_entity(rasa_app: SanicASGITestClient):
entity_name = "name"
entity_value = "Sara"
data = {INTENT_NAME_KEY: "greet", "entities": {entity_name: entity_value}}
_, response = await rasa_app.post(
"/conversations/test_trigger/trigger_intent", json=data
)

assert response.status == HTTPStatus.OK

parsed_content = response.json()
last_slot_set_event = [
event
for event in parsed_content["tracker"]["events"]
if event["event"] == "slot"
][-1]

assert parsed_content["tracker"]
assert parsed_content["messages"]
assert last_slot_set_event["name"] == entity_name
assert last_slot_set_event["value"] == entity_value


async def test_trigger_intent_with_missing_intent_name(rasa_app: SanicASGITestClient):
test_sender = "test_trigger_intent_with_missing_action_name"

Expand Down

0 comments on commit 3f054c3

Please sign in to comment.