Send automated email using rasa bot

I have to send automated email using rasa bot. I’m trying to store name and email of the user in slots. here are the snippets image image

image image image image

and action.py includes

Importing required modules

from typing import Any, Text, Dict, List

from rasa.core.actions.forms import FormAction from rasa_sdk import Action, Tracker from rasa_sdk.executor import CollectingDispatcher import smtplib

Creating new class to send emails.

class ActionEmail(Action):

def name(self) -> Text:
    # Name of the action
    return "action_email"

def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
    # Getting the data stored in the
    # slots and storing them in variables.
    user_name = tracker.get_slot("name")
    email_id = tracker.get_slot("email")

    # Code to send email
    # Creating connection using smtplib module
    s = smtplib.SMTP('smtp.gmail.com', 587)

    # Making connection secured
    s.starttls()

    # Authentication
    s.login("SENDER_EMAILID", "PASSWORD")

    # Message to be sent
    message = "Hello {} , This is a demo message".format(user_name)

    # Sending the mail
    s.sendmail("SENDER_EMAIL_ID", email_id, message)

    # Closing the connection
    s.quit()

    # Confirmation message
    dispatcher.utter_message(text="Email has been sent.")
    return []

but the output I’m getting is

can share the link of source code

1 Like

while entering email id it is giving an error :

2023-10-06 22:14:28 ERROR rasa.core.processor - Encountered an exception while running action ‘action_email’.Bot will continue, but the actions events are lost. Please check the logs of your action server for more information. Traceback (most recent call last): File “c:\users\satheesh bhukya\appdata\local\programs\python\python38\lib\site-packages\rasa\core\actions\action.py”, line 780, in run response: Any = await self.action_endpoint.request( File “c:\users\satheesh bhukya\appdata\local\programs\python\python38\lib\site-packages\rasa\utils\endpoints.py”, line 175, in request raise ClientResponseError( rasa.utils.endpoints.ClientResponseError: 404, Not Found, body=‘b’{“error”:“No registered action found for name 'action_email'.”,“action_name”:“action_email”}‘’

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File “c:\users\satheesh bhukya\appdata\local\programs\python\python38\lib\site-packages\rasa\core\processor.py”, line 960, in _run_action
events = await action.run( File “c:\users\satheesh bhukya\appdata\local\programs\python\python38\lib\site-packages\rasa\core\actions\action.py”, line 810, in run raise RasaException( rasa.shared.exceptions.RasaException: Failed to execute custom action ‘action_email’ can you resolve

1 Like