Skip to content

Instantly share code, notes, and snippets.

@pmutua
Created January 12, 2024 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmutua/0eb6c6c1b10decd1e8e8ea9251eb6f2a to your computer and use it in GitHub Desktop.
Save pmutua/0eb6c6c1b10decd1e8e8ea9251eb6f2a to your computer and use it in GitHub Desktop.
Example Swagger 2.0 JSON file for a Chatbot Assistance API with 10 entries (endpoints):
{
"swagger": "2.0",
"info": {
"title": "Chatbot Assistance API",
"description": "Provide customer support and assistance using chatbots.",
"version": "1.0.0"
},
"basePath": "/api",
"schemes": ["http", "https"],
"paths": {
"/chatbot/query": {
"post": {
"summary": "Submit Chatbot Query",
"description": "Endpoint to submit a customer query to the chatbot.",
"consumes": ["application/json"],
"produces": ["application/json"],
"parameters": [
{
"in": "body",
"name": "queryData",
"description": "Customer query data",
"schema": {
"$ref": "#/definitions/ChatbotQuery"
}
}
],
"responses": {
"200": {
"description": "Successful response",
"schema": {
"$ref": "#/definitions/ChatbotResponse"
}
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
}
}
}
},
"/chatbot/troubleshoot/{customerId}": {
"post": {
"summary": "Chatbot Troubleshoot",
"description": "Endpoint to initiate troubleshooting with the chatbot for a specific customer.",
"consumes": ["application/json"],
"produces": ["application/json"],
"parameters": [
{
"in": "path",
"name": "customerId",
"type": "string",
"description": "ID of the customer initiating troubleshooting."
},
{
"in": "body",
"name": "troubleshootData",
"description": "Troubleshooting data",
"schema": {
"$ref": "#/definitions/TroubleshootData"
}
}
],
"responses": {
"200": {
"description": "Successful response",
"schema": {
"$ref": "#/definitions/TroubleshootResult"
}
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
},
"404": {
"description": "Customer not found",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
}
}
}
},
"/chatbot/faqs": {
"get": {
"summary": "Get FAQs",
"description": "Endpoint to get a list of frequently asked questions handled by the chatbot.",
"produces": ["application/json"],
"responses": {
"200": {
"description": "Successful response",
"schema": {
"$ref": "#/definitions/FAQList"
}
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
}
}
}
},
"/chatbot/history/{customerId}": {
"get": {
"summary": "Get Chatbot Interaction History",
"description": "Endpoint to get the history of chatbot interactions for a specific customer.",
"produces": ["application/json"],
"parameters": [
{
"in": "path",
"name": "customerId",
"type": "string",
"description": "ID of the customer for chatbot interaction history retrieval."
}
],
"responses": {
"200": {
"description": "Successful response",
"schema": {
"$ref": "#/definitions/ChatbotInteractionHistory"
}
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
},
"404": {
"description": "Not found",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
}
}
}
}
},
"definitions": {
"ErrorModel": {
"type": "object",
"properties": {
"error": {
"type": "string",
"description": "Error message."
}
}
},
"ChatbotQuery": {
"type": "object",
"properties": {
"customerId": {
"type": "string",
"description": "ID of the customer submitting the query."
},
"query": {
"type": "string",
"description": "Customer's query or message to the chatbot."
}
},
"required": ["customerId", "query"]
},
"ChatbotResponse": {
"type": "object",
"properties": {
"customerId": {
"type": "string",
"description": "ID of the customer for whom the chatbot responded."
},
"response": {
"type": "string",
"description": "Chatbot's response to the customer's query."
}
}
},
"TroubleshootData": {
"type": "object",
"properties": {
"issue": {
"type": "string",
"description": "Description of the issue or problem the customer is facing."
},
"additionalDetails": {
"type": "string",
"description": "Additional details provided by the customer for troubleshooting."
}
},
"required": ["issue"]
},
"TroubleshootResult": {
"type": "object",
"properties": {
"customerId": {
"type": "string",
"description": "ID of the customer for troubleshooting."
},
"solution": {
"type": "string",
"description": "Chatbot's suggested solution for the troubleshooting."
}
}
},
"FAQ": {
"type": "object",
"properties": {
"question": {
"type": "string",
"description": "Frequently asked question."
},
"answer": {
"type": "string",
"description": "Answer to the frequently asked question."
}
}
},
"FAQList": {
"type": "object",
"properties": {
"faqs": {
"type": "array",
"items": {
"$ref": "#/definitions/FAQ"
},
"description": "List of frequently asked questions handled by the chatbot."
}
}
},
"ChatbotInteractionHistory": {
"type": "object",
"properties": {
"customerId": {
"type": "string",
"description": "ID of the customer for chatbot interaction history retrieval."
},
"interactions": {
"type": "array",
"items": {
"$ref": "#/definitions/ChatbotInteractionEntry"
},
"description": "List of chatbot interaction history entries."
}
}
},
"ChatbotInteractionEntry": {
"type": "object",
"properties": {
"timestamp": {
"type": "string",
"format": "date-time",
"description": "Timestamp of the chatbot interaction."
},
"query": {
"type": "string",
"description": "Customer's query or message to the chatbot."
},
"response": {
"type": "string",
"description": "Chatbot's response to the customer's query."
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment