How to collect data from button automatically with function

Hi guys, My chatbot has linked to the google worksheet file to collect database, normally I code the button in rasa manually like this screenshot. So can I change the button into automatically collect data with some functions ? without coding word by word. My chatbot is using Vietnamese language. Thanks a lot

Write Rasa stories that include user inputs triggering the intents defined in step 1. These stories should represent the conversation flow you want for crm data enrichment.

  • story: Collect data from Google Sheets steps:
    • intent: get_data
    • action: action_collect_data

Implement a custom action, let’s call it action_collect_data, in your Rasa project. This action should contain the logic to interact with Google Sheets and collect the required data.

actions.py

from typing import Any, Text, Dict, List from rasa_sdk import Action, Tracker from rasa_sdk.executor import CollectingDispatcher

class ActionCollectData(Action): def name(self) → Text: return “action_collect_data”

def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
    # Implement the logic to collect data from Google Sheets
    # You may use Google Sheets API or any other method here
    data = fetch_data_from_sheets()

    # Respond to the user
    dispatcher.utter_message(text=f"Here is the collected data: {data}")

    return []

You need to implement the fetch_data_from_sheets() function inside the ActionCollectData class. You can use the Google Sheets API to interact with your Google Sheets file. Make sure to install any necessary libraries and handle authentication.