edges:
  - id: botdojo/node/start_bec49-text_input-botdojo/node/language_model_agent_423ab-text_input
    label: text_input
    source: botdojo/node/start_bec49
    target: botdojo/node/language_model_agent_423ab
    sourceName: text_input
    targetName: text_input
  - id: botdojo/node/buffer_memory_4f94b-memory-botdojo/node/language_model_agent_423ab-memory
    label: memory
    source: botdojo/node/buffer_memory_4f94b
    target: botdojo/node/language_model_agent_423ab
    sourceName: memory
    targetName: memory
  - id: botdojo/node/code_tool_7d705-tool-botdojo/node/language_model_agent_423ab-tools
    label: tool
    source: botdojo/node/code_tool_7d705
    target: botdojo/node/language_model_agent_423ab
    sourceName: tool
    targetName: tools
  - id: botdojo/node/language_model_agent_423ab-text_output-botdojo/node/code_node_29e99-text_input
    label: text_output
    source: botdojo/node/language_model_agent_423ab
    target: botdojo/node/code_node_29e99
    sourceName: text_output
    targetName: text_input
  - id: botdojo/node/code_node_29e99-text_output-botdojo/node/end_203dd-text_output
    label: text_output
    source: botdojo/node/code_node_29e99
    target: botdojo/node/end_203dd
    sourceName: text_output
    targetName: text_output
  - id: botdojo/node/code_node_29e99-escalate_to_agent-botdojo/node/end_203dd-escalate_to_agent
    label: escalate_to_agent
    source: botdojo/node/code_node_29e99
    target: botdojo/node/end_203dd
    sourceName: escalate_to_agent
    targetName: escalate_to_agent
nodes:
  - id: botdojo/node/start_bec49
    icon: "@mui/icons-material/Start"
    label: Start
    version: "1.0"
    position:
      x: 53.04103905130961
      y: 116.43224381010845
    properties:
      inputSchema:
        schemaId: custom
        jsonSchema:
          type: object
          title: Text Input
          required:
            - text_input
          properties:
            text_input:
              type: string
              botdojo_order: 0
    definitionId: botdojo/node/start
    outputOptions: {}
  - id: botdojo/node/end_203dd
    icon: "@mui/icons-material/Output"
    label: End
    version: "1.0"
    position:
      x: 1402.5293922651936
      y: 268.8645303867403
    properties:
      inputSchema:
        schemaId: custom
        jsonSchema:
          type: object
          title: Text Output
          required:
            - text_output
          properties:
            text_output:
              type: string
              botdojo_order: 0
            escalate_to_agent:
              type: string
      outputSchema:
        schemaId: custom
        jsonSchema:
          type: object
          title: Text Input
          schema: https://botdojo.ai/schemas/text_input
          required:
            - text_output
            - escalate_to_agent
          properties:
            text_output:
              type: string
              botdojo_order: 0
            escalate_to_agent:
              type: boolean
              botdojo_order: 1
    definitionId: botdojo/node/end
    outputOptions: {}
  - id: botdojo/node/language_model_agent_423ab
    icon: /integrations/openai-white.svg
    label: AI Agent
    version: ""
    position:
      x: 720
      y: 41.5
    properties:
      maxIterations: 10
      functionConfig:
        inputSchema:
          schemaId: custom
          jsonSchema:
            type: object
            title: Text Input
            required:
              - text_input
            properties:
              text_input:
                type: string
                botdojo_order: 0
        outputSchema:
          schemaId: custom
          jsonSchema:
            type: object
            title: Text Output
            required:
              - text_output
            properties:
              text_output:
                type: string
                botdojo_order: 0
        languageModel:
          model_id: gpt-4-turbo
          provider_id: botdojo/integration/provider/openai
        promptTemplate:
          messages:
            - id: 41e957c0-9cc0-11ef-aff7-85458ec1a3c6
              role: system
              template: >
                You are a helpful agent with access to various tools to assist
                users effectively.


                Today's date is: {{now}}


                If you need to escalate to an agent, use the escalate_to_agent
                tool.


                When using tools (if they were available):

                1. Select the most appropriate tool for the task.

                2. Format your response exactly as shown in the JSON examples
                provided.

                3. Replace the placeholder values with relevant information
                based on the user's request.

                4. Ensure all required fields are filled correctly.


                Your task is to process the user's input: {{text_input}}


                Remember to maintain a friendly and professional tone in all
                interactions, and always strive to provide the most accurate and
                relevant information to the user. If you're unsure about how to
                proceed, ask the user for clarification.
            - id: 4e8704a0-9cc0-11ef-aff7-85458ec1a3c6
              role: chat_history_placeholder
              historyKey: chat_history
            - id: 41e957c1-9cc0-11ef-aff7-85458ec1a3c6
              role: user
              template: "{{text_input}}"
        languageModelOptions:
          modelId: gpt-4-turbo
          streamToChat: always
        providerSpecificConfig: {}
      hideStepDetails: false
      showStepsToUser: true
      finalOutputPromptTries: 3
      useParallelToolCalling: true
      warningThresholdMessage: null
      customFinalOutputMessage: null
      disableFinalOutputMessage: false
      warningThresholdIteration: null
    definitionId: botdojo/node/language_model_agent
    outputOptions: {}
  - id: botdojo/node/buffer_memory_4f94b
    icon: "@mui/icons-material/Memory"
    label: Buffer Memory
    version: "1.0"
    position:
      x: 358.41443238438717
      y: -192.2567028468385
    properties:
      memoryKey: buffer_memory
      numberOfMessages: 25
      userMessageBehavior: default
    definitionId: botdojo/node/buffer_memory
    outputOptions: {}
  - id: botdojo/node/code_tool_7d705
    icon: "@mui/icons-material/Code"
    label: escalate_to_agent (Code Node)
    version: "1.0"
    position:
      x: 355.97679558011055
      y: -7.242489762379805
    properties:
      functionConfig:
        allowEnv: true
        testInput: {}
        inputSchema:
          schemaId: custom
          jsonSchema:
            type: object
            title: Text Input
            required:
              - text_input
            properties:
              text_input:
                type: string
                botdojo_order: 0
        outputSchema:
          schemaId: custom
          jsonSchema:
            type: object
            title: Text Input
            schema: https://botdojo.ai/schemas/text_input
            required:
              - success
            properties:
              logs:
                type: array
                items:
                  type: string
                botdojo_order: 1
              success:
                type: boolean
                botdojo_order: 0
        allowCallback: true
        sandboxFunction:
          code: >+
            

            async function execute(
            	input: InputSchema, 
            	node:INode, 
            	context: IFlowContext): Promise<OutputSchema>
            {
            	const sessionState = await context.sessionState.get("default");
            	await sessionState.setVariable('escalate_to_agent', true);

            	
            	return {
            		success: true,
            		logs: [JSON.stringify(sessionState), JSON.stringify(await sessionState.getVariable('escalate_to_agent'))]
            	}
            }

          options: {}
          language: typescript
      toolNameOverride: escalate_to_agent
      toolInstructionsOverride: If the user ever asks to talk to our agent, you can
        use this tool to escalate to an agent
    definitionId: botdojo/node/code_tool
    outputOptions: {}
  - id: botdojo/node/code_node_29e99
    icon: "@mui/icons-material/Code"
    label: Code
    version: "1.0"
    position:
      x: 1012.7253223191785
      y: 224.93618784530378
    properties:
      functionConfig:
        allowEnv: true
        testInput: {}
        inputSchema:
          schemaId: custom
          jsonSchema:
            type: object
            title: Text Input
            required:
              - text_input
            properties:
              text_input:
                type: string
                botdojo_order: 0
        outputSchema:
          schemaId: custom
          jsonSchema:
            type: object
            title: Text Input
            schema: https://botdojo.ai/schemas/text_input
            required:
              - text_output
            properties:
              logs:
                type: array
                items:
                  type: string
                botdojo_order: 2
              text_output:
                type: string
                botdojo_order: 0
              escalate_to_agent:
                type: boolean
                botdojo_order: 1
        allowCallback: true
        sandboxFunction:
          code: >+
            

            async function execute(
            	input: InputSchema, 
            	node:INode, 
            	context: IFlowContext): Promise<OutputSchema>
            {
            	const ss = await context.sessionState.get("default");
            	const escalate_to_agent = (await ss.getVariable("escalate_to_agent")) || false;

            	return {
            		text_output: input.text_input,
            		escalate_to_agent: escalate_to_agent,
            		logs: [JSON.stringify(ss)]
            	}

            }

          options: {}
          language: typescript
    definitionId: botdojo/node/code_node
    outputOptions: {}
definition:
  name: L1 Agent Example
  categories:
    - Featured
  chatConfig:
    welcomeMessage: >+
      I'm an agent that can search the web to answer questions.


      Try asking me "What's the weather today in Austin?" or "What's today's
      news?"


      If you want to change this welcome message, go to ⚙️ > Chat > Chat
      Settings > Welcome Message.

  properties: []
  description: A helpful chatbot that can have a typical conversation and use the
    Internet to get the latest news and information
  readmeMarkdown: >+
    An agent that can search the web to answer questions.


    Try asking me "What's the weather today in Austin?" or "What's today's
    news?"

  packageExportTypes: []
propertyOverrides: []
