Trigger action on every message

I want to trigger an action on every user message, how can I do this?

this is my schema

{
  "openapi": "3.1.0",
  "info": {
    "title": "Get answer",
    "description": "Retrieves answer for the question.Call this api for every user message",
    "version": "v1.0.0"
  },
  "servers": [
    {
      "url": "https://xxx-xxx-xx-232-58.ngrok-free.app"
    }
  ],
  "paths": {
    "/api/openai/receive-message": {
      "post": {
        "summary": "Receives a user message and triggers an action.",
        "operationId": "receiveMessage",
        "x-openai-isConsequential": false,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "message": {
                    "type": "string",
                    "description": "The message content."
                  },
                  "userId": {
                    "type": "string",
                    "description": "Unique identifier for the user."
                  },
                  "timestamp": {
                    "type": "string",
                    "description": "The time at which the message was sent."
                  }
                },
                "required": [
                  "message",
                  "userId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {}
  }
}

my use-case is, for every message I want to trigger the action and based on the response from the api, I want gpt to respond to user.

How can I acheive this?

It seems like you are attempting to break this promise:

image

1 Like