NUWAY API

Chat

Send a customer's message to your AI workers and get the reply. The AI uses your trained knowledge, your products and your team's calendars, and it remembers the conversation.

Send a message

POST /api/v1/external/chat

Start a conversation, or continue one by passing the session_id from an earlier reply.

Request body

NameDescription
message string requiredThe customer's message, 1–8,000 characters.
session_id stringContinues an existing conversation. Pass the session_id from an earlier reply; omit it to start a new one. Letters, digits and _ - : ., up to 100 characters.
agent stringWhich AI worker should answer. auto (default) picks the right worker for each message, like your website widget. Alternatives: support, sales, scheduler.
customer objectWho is asking. Saved on the conversation and its lead.
customer.email stringThe customer's email.
customer.first_name stringThe customer's first name.
customer.last_name stringThe customer's last name.

Example request

# Start a conversation
curl https://ai.nuway.co/api/v1/external/chat \
  -H "X-API-KEY: $NUWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
        "message": "Do you offer office tours?",
        "customer": {"email": "[email protected]", "first_name": "Jane", "last_name": "Doe"}
      }'
# Continue it with the session_id from the reply
curl https://ai.nuway.co/api/v1/external/chat \
  -H "X-API-KEY: $NUWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"message": "Yes, next Tuesday morning please", "session_id": "api_0a8a897f15f547a7839987037932a43b"}'
// Node.js 18+
async function askNuway(message, sessionId) {
  const res = await fetch("https://ai.nuway.co/api/v1/external/chat", {
    method: "POST",
    headers: {
      "X-API-KEY": process.env.NUWAY_API_KEY,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ message, session_id: sessionId }),
    signal: AbortSignal.timeout(60_000),
  });
  if (!res.ok) throw new Error(`NUWAY ${res.status}: ${JSON.stringify(await res.json())}`);
  return res.json(); // { session_id, reply, ... }
}
import os
import requests
def ask_nuway(message, session_id=None):
    r = requests.post(
        "https://ai.nuway.co/api/v1/external/chat",
        headers={"X-API-KEY": os.environ["NUWAY_API_KEY"]},
        json={"message": message, **({"session_id": session_id} if session_id else {})},
        timeout=60,
    )
    r.raise_for_status()
    return r.json()  # {"session_id": ..., "reply": ..., ...}

Response

{
  "session_id": "api_0a8a897f15f547a7839987037932a43b",
  "reply": "Yes, we do offer office tours! Would you like me to book one for you?",
  "agent": "scheduler",
  "answer_type": "ANSWER",
  "ask_email": false,
  "message_id": 36344,
  "execution_time_ms": 3120
}

Response fields

NameDescription
session_id stringThe conversation's ID. Send it with the next message to continue.
reply stringThe AI's answer, ready to show the customer. It may contain simple Markdown (**bold**, lists, links).
agent stringThe worker that answered: support, sales, scheduler or auto.
answer_type stringANSWER, or NO_ANSWER when the AI couldn't answer from your knowledge. Unanswered questions also appear in your dashboard so you can teach the AI.
ask_email booleantrue when the AI would like the customer's email, for example so your team can follow up. A good moment to show an email field.
message_id integerID of the stored reply.
execution_time_ms integerHow long the reply took.

Errors 402 out of credit, 404 the session_id belongs to another company, 422 invalid input or an agent your account doesn't have, 502 the AI couldn't reply (retry).

Booking meetings through chat

Meetings are booked in conversation, the same way as on your website. Your customer asks for a meeting, and the AI suggests team members and times, collects the customer's name and email, and books it on the team member's calendar (Google, Outlook, Cal.com, Calendly, or NUWAY's own calendar).

The customer confirms with a code

To protect your calendar, the AI emails the customer a verification code before booking. The customer types the code into the chat as their next message, and the meeting is confirmed with an email to both sides. Make sure your chat interface lets the customer send that code.

Using your own session IDs

You can pass your own ID as session_id (for example crm-ticket-8812) to start a conversation under it. Session IDs are unique across NUWAY, so prefix them with something specific to your company. An ID already used by another company returns 404; leaving session_id out always gives you a fresh one.