The Chat API endpoint allows you to send messages to a conversation and receive responses.

Method: POST
URL: https://api.trypopcorn.ai/chat

Headers

  • POPCORN-API-KEY (string, required) - Your API key, provided by the Popcorn team.

Parameters

  • Body Parameters:
    • userId (string, required) - A unique identifier for the user, such as an email, phone number, or another predefined ID used by your system.
    • message (string, required) - The message to be sent in the conversation. The userId is used to identify which conversation the new message belongs to.

Example Request

POST https://api.trypopcorn.ai/chat
Content-Type: application/json
POPCORN-API-KEY: your_popcorn_api_key

{
  "userId": "john@smith.com",
  "message": "Hello there!"
}

Example Response

{
  "response": "Hello! How can I assist you today?",
  "timestamp": "2024-03-03T14:01:51.036Z"
}

If there’s an error, the response may look like:

{
  "error": "Request error: userId is required"
}

Errors

  • 400 - Invalid request, e.g., missing recipientNumber or templateId.
  • 500 - Internal server error.