Skip to content

Internal Actions

Nilson Lazarin edited this page Mar 13, 2024 · 4 revisions
  • .mailer.credentials(E,K) - set e-mail credentials.
  • .mailer.eMailService([I,p],[O,q]) - set e-mail provider configurations.

Where:

  • p is a literal that represents the input protocol (only available option is: imaps).
  • q is a literal that represents the output protocol (only available option is: smtpOverTLS).
  • E is a string that represents the e-mail account (e.g., "jomi@example.com");
  • I is a string that represents the FQDN of the input e-mail server (e.g., "imap.example.com");
  • K is a string that represents the e-mail password;
  • O is a string that represents the FQDN of the output e-mail server(e.g., "smtp.example.com");

How to use?

1. An example in AgentSpeak(L), using Jason-CLI.

How to install the Jason-CLI ?

i) In a terminal command, create a Multiagent System Project, using the command below:

jason app create multiAgentSystem --console

ii) Create a directory lib in the project folder and download the MailerAgent library into the library folder, using the command below:

wget https://github.com/chon-group/Mailer/releases/latest/download/MailerAgent.jar -P multiAgentSystem/lib/

iii) Change the file multiAgentSystem/multiAgentSystem.mas2j, including the content below:

MAS multiAgentSystem {
    agents: alice agentArchClass jason.Mailer;
    aslSourcePath: "src/agt";
}

iv) Change the file multiAgentSystem/src/agt/alice.asl, including the content below and changing .mailer.credentials information.

In this example we are using a free GMX Mail Account. To use others Service Email Provider, see ProvidersExamples

// Agent alice in project multiAgentSystem
/* Initial beliefs and rules */

/* Initial goals */
!confEMail.

/* Plans */
+!confEMail<-
    /* The Account username and password */
    .mailer.credentials("INSERT-HERE-THE-EMAIL","INSERT-HERE-THE-PASS");

    /* The Provider configurations */
    .mailer.eMailService(["imap.gmx.com",imaps],["mail.gmx.com",smtpOverTLS]);                  /* To use GMX       */ 
    //.mailer.eMailService(["imap.gmail.com",imaps],["smtp.gmail.com",smtpOverTLS]);            /* To use GMail     */ 
    //.mailer.eMailService(["imap.mail.yahoo.com",imaps],["smtp.mail.yahoo.com",smtpOverTLS]);  /* To use Yahoo     */ 
    //.mailer.eMailService(["imap.fastmail.com",imaps],["smtp.fastmail.com",smtpOverTLS]);      /* To use FastMail  */ 
.

+greeting[source(Email)] <-
        .print("Hello ", Email," nice to meet you!");
        .mailer.sendEMail(Email,tell,aliceAgent(online));
        .print("Now, try to send me a plan...");
.

v) Execute the Multiagent System

jason multiAgentSystem/multiAgentSystem.mas2j

vi) If all is correct, the expected output is the follow.

2. An example of Human-Agent interaction.

i) The humans can interact directly with a Jason Agent, over e-mail, since that e-mail be an KQML message.

  • The e-mail subject is interpreted as a KQML Illocutionary force;
  • The content is interpreted as AgentSpeak(L) code.

Below, the human is sending the belief (greeting) to the agent.

ii) The agent can send an e-mail to a human too

As the agent has a belief plan in your initial code (+greeting[source(Email)]...), it can reply to a human.

iii) The message for a human is a KQML message

In this example, the agent sends a belief (aliceAgent(online)) for the human.

3. An example where a Human requests the execution of a specific plan for an Agent

i) The human can teach the agent, sending a specific plan.

ii) The human can request the execution of a plan for the Agent.

Below is shown the execution of the plan (stopTest), received from the human.