YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
GoogleDialogFlowCxChatBot.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_GOOGLEDIALOGCXBOT_H
7#define YARP_GOOGLEDIALOGCXBOT_H
8
10#include <yarp/dev/IChatBot.h>
11#include <yarp/os/Network.h>
12#include <algorithm>
13
14#include <google/cloud/dialogflow_cx/agents_client.h>
15#include <google/cloud/dialogflow/cx/v3/agent.pb.h>
16#include <google/cloud/dialogflow_cx/sessions_client.h>
17#include <google/cloud/dialogflow/cx/v3/session.grpc.pb.h>
18#include <google/cloud/dialogflow/cx/v3/session.pb.h>
19#include <grpcpp/grpcpp.h>
20
22
38{
39public:
45 ~GoogleDialogFlowCxChatBot() override = default;
46
47 // DeviceDriver
48 bool open(yarp::os::Searchable& config) override;
49 bool close() override;
50
51 // IChatBot
52 yarp::dev::ReturnValue interact(const std::string& messageIn, std::string& messageOut) override;
53 yarp::dev::ReturnValue setLanguage(const std::string& language) override;
54 yarp::dev::ReturnValue getLanguage(std::string& language) override;
55 yarp::dev::ReturnValue getStatus(std::string& status) override;
56 yarp::dev::ReturnValue resetBot() override;
57
58private:
59 std::string m_agentId;
60 std::string m_sessionId;
61 std::string m_currentPage;
62 std::shared_ptr<grpc::Channel> m_channel;
63 std::unique_ptr<google::cloud::dialogflow::cx::v3::Sessions::Stub> m_sessionStub;
64 std::shared_ptr<google::cloud::dialogflow_cx::SessionsClient> m_session{nullptr};
65
66 std::string _getRandSession_();
67};
68
69#endif // YARP_GOOGLEDIALOGCXBOT_H
This class is the parameters parser for class GoogleDialogFlowCxChatBot.
googleDialogFlowCxChatBot: A yarp device to enable interaction with Google's DialogFlow CX service
GoogleDialogFlowCxChatBot()=default
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
yarp::dev::ReturnValue interact(const std::string &messageIn, std::string &messageOut) override
Sends a message to the chatbot.
yarp::dev::ReturnValue getLanguage(std::string &language) override
Gets the current chatbot language.
yarp::dev::ReturnValue getStatus(std::string &status) override
Gets the current status of the bot.
GoogleDialogFlowCxChatBot(const GoogleDialogFlowCxChatBot &)=delete
yarp::dev::ReturnValue resetBot() override
Resets the chatbot.
GoogleDialogFlowCxChatBot(GoogleDialogFlowCxChatBot &&) noexcept=delete
bool close() override
Close the DeviceDriver.
yarp::dev::ReturnValue setLanguage(const std::string &language) override
Sets the chat bot language.
Interface implemented by all device drivers.
IChatBot interface.
Definition IChatBot.h:26
STL namespace.
The main, catch-all namespace for YARP.
Definition dirs.h:16