To fill in ListSlot

is this line correct?

        return [SlotSet("ocr_result", (datetime, price, address_from, address_to))]

the origin code is:

from typing import Dict, Text, Any, List, Union

from rasa_sdk import Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.forms import FormValidationAction
from rasa_sdk import Action
from rasa_sdk.events import SlotSet
from actions.ocrapi import get_ocr_api
import json


class ActionRequestOcrs(Action):
    def name(self) -> Text:
        return "action_request_ocr" 
    def run(
            self,
            dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any],) -> List[Dict]:

        img_path = tracker.get_slot('ticket')
        datetime,price,address_from,address_to,ocr_data="","","","",""
        datetime,price,address_from,address_to,ocr_data = self.get_ocr_response(img_path)
        dispatcher.utter_message(ocr_data)
        return [SlotSet("ocr_result", (datetime, price, address_from, address_to))]```
  • (datetime, price, address_from, address_to) is a tuple
  • [datetime, price, address_from, address_to] is a list

If it works, it’s correct

@AlenChuan If your API fetching these values? print all the value and check.

yes I have an API, and I asked my Working Group Leader if I could show it to someone else but he said it’s only for our project, so I couldn’t paste it here. But it fetches all the text messages of the tickets, receipts and so on. In this project I’m working on it only requires 4 values.

thx, it works.

1 Like

Great, please mark the answer as solution to mark the thread as solved :slight_smile: