<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>L. Grassi); carmine.recchiuto@dibris.unige.it (C. T. Recchiuto);
antonio.sgorbissa@unige.it (A. Sgorbissa)
 https://www.researchgate.net/profile/Lucrezia-Grassi (L. Grassi);
https://www.researchgate.net/profile/Carmine-Recchiuto (C. T. Recchiuto);
https://www.researchgate.net/profile/Antonio-Sgorbissa (A. Sgorbissa)</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Cloud Services for Social Robots and Artificial Agents</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Lucrezia Grassi</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Carmine Tommaso Recchiuto</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Antonio Sgorbissa</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Laboratorium - DIBRIS, Università di Genova</institution>
          ,
          <addr-line>via all'Opera Pia 13, 16145, Genova</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2021</year>
      </pub-date>
      <volume>000</volume>
      <fpage>0</fpage>
      <lpage>0001</lpage>
      <abstract>
        <p>This work presents the design and the implementation of CAIR: a cloud system for knowledge-based interaction devised for Social Robots and other conversational agents. The system is structured in a way that it can be easily expanded by adding new services that improve the capabilities of the clients connected to the Cloud. Another key feature of the system is that it has been designed to make the development of its clients straightforward: in this way, multiple devices (e.g., robots, computers, smartphones, etc.) can be easily endowed with the capability of autonomously interacting with the user, understanding when to perform specific actions, and exploiting all the information provided by services on the Cloud.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Cloud Robotics</kwd>
        <kwd>REST API</kwd>
        <kwd>Client-Server Architecture</kwd>
        <kwd>Socially Assistive Robots</kwd>
        <kwd>Human-Robot Interaction</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        CARESSES1 is an international, multidisciplinary project whose goal is to design the first robots
that can assist older people and adapt to the culture of the individual they are taking care of
[
        <xref ref-type="bibr" rid="ref1 ref2">1, 2</xref>
        ]. The robots can help the users in many ways including reminding them to take their
medication, encouraging them to keep active, helping them keep in touch with family and
friends. Each action is performed with attention to the older person’s customs, cultural practices
and individual preferences. In CARESSES, the ability of the companion robot to naturally
converse with the user has been achieved by creating a framework for cultural knowledge
representation that relies on an Ontology [
        <xref ref-type="bibr" rid="ref3 ref4">3, 4</xref>
        ]. A major limitation of the CARESSES system is
that only one device at a time can connect to the server and exploit all the capabilities provided
by the system. Moreover, its server stores the information related to a single client, and it
manages all the connections, even from diferent devices, as coming from the same user. This
kind of implementation also prevents the system to allow for an expansion of the knowledge
base from multiple users.
      </p>
      <p>
        Recently, it has become more and more common to exploit cloud technologies to improve
the eficiency of many devices and systems. In the robotics field, this practice is defined as cloud
robotics, i.e. the use of remote computing resources to enable greater memory, computational
power, collective learning and inter-connectivity for robotics applications [
        <xref ref-type="bibr" rid="ref5 ref6">5, 6</xref>
        ].
      </p>
      <p>This paper describes the cloud system that has been designed based on the underlying
principles of the CARESSES system, but completely modifying its architecture to ofer a set of
web services for multiple robots and devices.</p>
      <p>
        The CAIR system has been developed by taking advantage of the rich knowledge base and
the dialogue mechanism developed during the CARESSES project, intending to create a system
much easier to use and able to manage contemporary connections from multiple users. The
system is based on the use of REST APIs [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] that provide many advantages such as scalability,
lfexibility, portability and independence (see Section 2). CAIR web services allow the connected
clients to manage a rich conversation with the users and to receive Plans to be executed, if
possible, on the client device. Moreover, such architecture allows to efectively exploit the
already implemented mechanism for knowledge expansion [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], which will be integrated into
the following versions of the system.
      </p>
      <p>The system for knowledge-based autonomous interaction described in this work can be easily
used by most devices with Internet connectivity, able to acquire an input through a keyboard or
a microphone, and provide an output through a screen or a speaker (e.g., robots, computers,
smartphones, smartwatches, etc.).</p>
    </sec>
    <sec id="sec-2">
      <title>2. System Architecture</title>
      <p>The system is based on a client-server architecture and it has been designed in a way that it
is easy to add new functionalities to improve its performance, and it is easy to be used by the
clients.</p>
      <p>Figure 1 depicts the proposed architecture. The server is composed of two web services
developed in Python: (1) the Dialogue Manager service that manages the dialogue and analyzes
the user sentence to recognize the intention of talking about a specific topic, and (2) the Plan
Manager service that recognizes the intention of the user to make the agent execute a specific
action. To provide appropriate answers and plans, the server exploits an Ontology containing
all the topics, keywords, sentences and plans used during the interaction with the user. The
Flask-RESTful2 framework has been used when developing the web services.</p>
      <p>The client can perform requests to the server using REST APIs. REST is a set of rules that
should be followed when creating the API. One of these rules states that the client should be
able to get a piece of data (called a resource) when linked to a specific URI. Each URI is called a
request, while the data sent back to the user is called a response. Any web service that obeys the
REST constraints is informally described as RESTful. Due to the separation between client and
server, this protocol makes it easy for developments across the various areas of a project to take
place independently. In addition, the REST API adapts at all times to the working syntax and
platform. This ofers the opportunity to try several environments while developing.</p>
      <p>The client acquires the user sentence, sends it to the server, parses the response, executes the
received Plan and/or replies with the dialogue sentence returned by the Dialogue Manager.</p>
      <p>2https://flask-restful.readthedocs.io/en/latest/</p>
      <sec id="sec-2-1">
        <title>2.1. Dialogue Manager service</title>
        <p>
          The Dialogue Manager service is in charge of managing the dialogue. To provide the appropriate
response to the user, the Dialogue Manager service requires as input the user sentence and the
client state. As mentioned before, the ability of the system to naturally converse with the user
has been achieved by creating a framework for cultural knowledge representation that relies on
an Ontology [
          <xref ref-type="bibr" rid="ref3 ref4">3, 4</xref>
          ]. However, to deal with representations of the world that may vary across
diferent cultures [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ], the Ontology is organized into three layers, as explained more in detail in
[
          <xref ref-type="bibr" rid="ref10 ref4">10, 4</xref>
          ]. The Ontology structure is used to build the Dialogue Tree (DT) and some additional
ifles, namely the Topics keywords, Topics likeliness and Topics sentences, which are ultimately
fed to the conversation system to chit-chat with the user.
        </p>
        <p>
          Based on the Dialogue Tree, the key ideas for knowledge-driven conversation can be briefly
summarized as follows (the whole process [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ] is more complex).
        </p>
        <p>Each time a user sentence is acquired:
1. A Dialogue Management algorithm (either keyword-based or based on more advanced
topic classification techniques) is applied to check if the user’s sentence may trigger one
of the topics in the DT by jumping to the corresponding node;
2. If no topics are triggered, the conversation follows one of the branches of the DT (according
to policies that take into account the user’s cultural background and personal preferences).</p>
        <p>The system continues in this way, proposing sentences corresponding to a node and acquiring
the user’s feedback that can be used to update the user’s preferences and/or determine the next
node to move to.</p>
      </sec>
      <sec id="sec-2-2">
        <title>2.2. Plan Manager Service</title>
        <p>As shown in Figure 1, other than providing the dialogue reply and the updated client state,
the Dialogue Manager service also calls the Plan Manager service, working as an intermediary
between the client and such service. However, the client could directly call this service if not
interested in managing the dialogue.</p>
        <p>The Plan Manager service receives as input the user sentence. Its purpose is to find a match
between such sentence and one of the trigger sentences of a specific Intent. An Intent is defined
by (i) a set of trigger sentences (built using regexes), (ii) one or more plan-specific sentences (if
any), (iii) a KBPlan (if any), (iv) and a Plan (if any) (Figure 2).</p>
        <p>Trigger sentences (i) are used to check if the user sentence matches with the corresponding
Intent. Such sentences are currently modeled with regexes, and allow to extract parameters
from the matched sentence that can be used to dynamically compose the plan sentences, the
plan and the KBPlan. Besides trigger sentences, also plan-specific sentences have been defined
(ii), which are used by the system to reply when an intent is detected.</p>
        <p>A KBPlan, where KB stands for Knowledge Base, is a sequence of actions meant to afect the
knowledge base and/or the flow of the dialogue. For instance, if the user says “I love music",
this sentence will match the trigger sentences of the Appreciation Intent (Figure 2) meant to
recognize the user’s appreciation for something and extract the loved thing as a parameter. The
KBPlan of this Intent is composed of two actions: the first one increases the probability that the
user wants to talk about the extracted parameter, while the second one brings the information
that the system should jump to that conversation topic (if present in the Ontology).</p>
        <p>A Plan is a sequence of actions that should be executed on the client as it does not afect
the knowledge base nor the flow of the dialogue. For instance, if the user says “Play the song
Yesterday", this sentence will match one of the trigger sentences of the Music Intent (Figure 2)
that recognizes the user intention to some music. The plan of this Intent is composed of a single
action carrying the information that the client should play the song having the title contained
in the parameter field (see Section 2.3).</p>
        <p>If the Plan Manager service finds a match with an Intent, a response containing the KBPlan,
the plan sentence, and the plan is returned to the Dialogue Manager service (see Figure 1).
The KBPlan is managed by the Dialogue Manager, as it directly afects the continuation of the
dialogue, while the plan sentence and the plan are not used by this service. Once the Dialogue
Manager service has chosen the most appropriate answer for the user based on the information
contained in the client state, the previous user sentence, and, eventually, the KBPlan, it returns
a response to the client. Such a response contains the updated client state, the plan sentence,
the plan, and the dialogue sentence (i.e., the actual continuation of the dialogue).</p>
      </sec>
      <sec id="sec-2-3">
        <title>2.3. Client</title>
        <p>A client for CAIR can be easily developed for most devices with Internet connectivity such as
robots, computers, smartphones, smartwatches, etc. The first thing that the client should do
is to perform a PUT request to the server, in particular to the Dialogue Manager service, to
obtain the initial client state and the first sentence of the conversation. The client state should
be stored locally and retrieved before all the following requests. Afterwards, the client should
acquire the user input, send it to the server along with the client state with a GET request,
retrieve and manage the response. This last operation expects the system to communicate the
Intent reply to the user, perform the actions contained in the plan field of the response, and
eventually continue the dialogue by communicating the sentence reply. If the client is not able
to execute the actions it can ignore them and consider only the sentence reply.</p>
        <p>An example of a simple client for PC can be found in this GitHub repository3. The repository
contains also a PDF guide with a detailed explanation of the code and of all Plans that the
server can return to the client based on the Intent that has been matched. Another documented
example of a full client for the SoftBank Robotics robots Pepper and Nao, that manages all
the Plans returned by the server, can be found here4. A video showing some extracts of the
interaction is available on YouTube5.</p>
        <p>3https://github.com/lucregrassi/CAIRclient_instructions.git
4https://github.com/lucregrassi/CAIRclient/tree/develop
5https://www.youtube.com/watch?v=UdbYGytd07w</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>C.</given-names>
            <surname>Papadopoulos</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Castro</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Nigath</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Davidson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Faulkes</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Menicatti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. A.</given-names>
            <surname>Khaliq</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Recchiuto</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Battistuzzi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Randhawa</surname>
          </string-name>
          , et al.,
          <article-title>The caresses randomised controlled trial: Exploring the health-related impact of culturally competent artificial intelligence embedded into socially assistive robots and tested in older adult care homes</article-title>
          ,
          <source>International Journal of Social Robotics</source>
          (
          <year>2021</year>
          )
          <fpage>1</fpage>
          -
          <lpage>12</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>A.</given-names>
            <surname>Khaliq</surname>
          </string-name>
          ,
          <string-name>
            <given-names>U.</given-names>
            <surname>Kockemann</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Pecora</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Safiotti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Bruno</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Recchiuto</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Sgorbissa</surname>
          </string-name>
          , H.
          <string-name>
            <surname>-D. Bui</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          <string-name>
            <surname>Chong</surname>
          </string-name>
          ,
          <article-title>Culturally aware planning and execution of robot actions</article-title>
          ,
          <year>2018</year>
          , pp.
          <fpage>326</fpage>
          -
          <lpage>332</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>N.</given-names>
            <surname>Guarino</surname>
          </string-name>
          ,
          <article-title>Formal ontology and information systems</article-title>
          ,
          <source>FOIS'98 Conf</source>
          (
          <year>1998</year>
          )
          <fpage>81</fpage>
          -
          <lpage>97</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>B.</given-names>
            <surname>Bruno</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. T.</given-names>
            <surname>Recchiuto</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Papadopoulos</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Safiotti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Koulouglioti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Menicatti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Mastrogiovanni</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Zaccaria</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Sgorbissa</surname>
          </string-name>
          ,
          <article-title>Knowledge representation for culturally competent personal robots: requirements, design principles, implementation, and assessment</article-title>
          ,
          <source>International Journal of Social Robotics</source>
          <volume>11</volume>
          (
          <year>2019</year>
          )
          <fpage>515</fpage>
          -
          <lpage>538</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>J.</given-names>
            <surname>Wan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Tang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Yan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. V.</given-names>
            <surname>Vasilakos</surname>
          </string-name>
          ,
          <article-title>Cloud robotics: Current status and open issues</article-title>
          ,
          <source>IEEE Access 4</source>
          (
          <year>2016</year>
          )
          <fpage>2797</fpage>
          -
          <lpage>2807</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>C.</given-names>
            <surname>Recchuto</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Gava</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Grassi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Grillo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Lagomarsino</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Lanza</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Liu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Papadopoulos</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Papadopoulos</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Scalmato</surname>
          </string-name>
          , et al.,
          <article-title>Cloud services for culture aware conversation: Socially assistive robots and virtual assistants</article-title>
          ,
          <source>in: 2020 17th International Conference on Ubiquitous Robots (UR)</source>
          , IEEE,
          <year>2020</year>
          , pp.
          <fpage>270</fpage>
          -
          <lpage>277</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>M.</given-names>
            <surname>Masse</surname>
          </string-name>
          ,
          <article-title>Rest api design rulebook: Designing consistent restful web service interfaces</article-title>
          ,
          <source>O'Reilly</source>
          (
          <year>2011</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>L.</given-names>
            <surname>Grassi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Recchiuto</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Sgorbissa</surname>
          </string-name>
          ,
          <article-title>Knowledge triggering, extraction and storage via human-robot verbal interaction</article-title>
          ,
          <source>Robotics and Autonomous Systems</source>
          <volume>148</volume>
          (
          <year>2022</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>M.</given-names>
            <surname>Carrithers</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Candea</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Sykes</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Holbraad</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Venkatesan</surname>
          </string-name>
          ,
          <article-title>Ontology is just another word for culture: Motion tabled at the 2008 meeting of the group for debates in anthropological theory</article-title>
          , university of manchester,
          <source>Critique of anthropology 30</source>
          (
          <year>2010</year>
          )
          <fpage>152</fpage>
          -
          <lpage>200</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>C. T.</given-names>
            <surname>Recchiuto</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Sgorbissa</surname>
          </string-name>
          ,
          <article-title>A feasibility study of culture-aware cloud services for conversational robots</article-title>
          ,
          <source>IEEE Robotics and Automation Letters</source>
          <volume>5</volume>
          (
          <year>2020</year>
          )
          <fpage>6559</fpage>
          -
          <lpage>6566</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>