Mike
Mike

Reputation: 466

DialogFlow (Can you have one master agent which controls other agents?)

Something like Angular where its modularized. Modules are a great way to organize an application and extend it with capabilities from external libraries.

Have one Master agent where its connected to different agents?

Upvotes: 1

Views: 578

Answers (1)

sid8491
sid8491

Reputation: 6800

You can make multiple agents then write a script where you would call the agents using the sdk based on the condition.

Each agent would have a project id which will be used to make the connection to the agent.

Below is example how to it in python:

import dialogflow

def detect_intent_texts(project_id, session_id, text)
    session_client = dialogflow.SessionsClient()

    session = session_client.session_path(project_id, session_id)
    text_input = dialogflow.types.TextInput(text=text)

    query_input = dialogflow.types.QueryInput(text=text_input)

    response = session_client.detect_intent(
        session=session, query_input=query_input)


session_id = initialize_session_id_from_application
text = get_text_from_application

if condition == 1:
    res = detect_intent_texts(project_id_1, session_id, text)
elif condition == 2:
    res = detect_intent_texts(project_id_2, session_id, text)
else:
    res = detect_intent_texts(project_id_3, session_id, text)

You can view the user query using res.query_result.query_text, and detected intent using res.query_result.intent.display_name.

Do note that different intent will create different sessions internally.

Hope it helps.

Upvotes: 1

Related Questions