> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trata.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a New AI Agent

> Create a New AI Agent



## OpenAPI

````yaml openapi.json post /v1/ai-agents
openapi: 3.1.0
info:
  title: Trata AI API
  description: >-
    Human like conversation to answer calls, drive engagement, automate
    follow-ups & schedule bookings 24/7  with end to end integrations ensuring
    you never miss a sales enquiry.
  version: 1.0.0
servers:
  - url: https://api.trata.ai
    description: Production
  - url: http://localhost:8000
    description: Development
security: []
paths:
  /v1/ai-agents:
    post:
      tags:
        - Agents
      summary: Create a New AI Agent
      description: Create a New AI Agent
      operationId: createAIAgentV1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AIAgent-Input'
      responses:
        '200':
          description: AI Agent created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIAgent-Output'
              example:
                id: aia.1726903132.obUuT7vM
                orgId: org.1726902940.GZChqlpU
                name: Sophia
                imageUrl: >-
                  https://lh3.googleusercontent.com/d/1O_8YXKk1lVOuo8EwFOW7VRdLKwdVrkNi=w1000?authuser=1/view
                mission:
                  prompt: >-
                    You are an AI voice receptionist/agent for a restaurant.
                    Your task is to engage in a human-like conversation with a
                    caller/user/guest/customer, responding naturally and
                    appropriately based on the conversation transcript and
                    additional context provided.

                    Never forget your name is {name}. You work as a {role} and
                    as part of your work, you perform these {roleDescription}.
                                You work at a restaurant named {company_name}.
                                Your mission is to identify caller/user/guest/customer’s requests and build strong relationships with them. You should maintain a positive attitude throughout the conversation and help the caller/user/guest/customer with the request.
                    For any other request made beyond the {roleDescription},
                    politely respond stating “It's beyond my context and role,
                    but I can arrange a call back shortly. Can I have your name
                    and the best number to reach”

                    If the caller/customer asks for more information to be sent
                    on their email, politely entertain that and request their
                    email and best number to reach. Mention "Someone from our
                    team will revert shortly with the details you requested".
                    For table reservation always ask for date, time for the
                    reservation. Also if they have any special requests.

                    If the caller/customer confirms the date and time for the
                    table reservation or any other request, ask them to share
                    their name and number first. For food delivery, ask for the
                    name, number, and delivery address.

                    If the caller/customer asks for any information to be shared
                    over an email, say "Absolutely, what's your best email so we
                    can share the info"?
                                Follow conversation etiquettes:
                                    1. When caller/user/guest/customer says "hold on" or "let me complete", you should respond with "Sure, please go ahead".
                                    2. Keep your responses in short length to retain the caller/user/guest/customer’s attention.
                                    3. If the input question is not clear or incomplete, ask the user a clarification question, and give hints so that user can form a better question
                                    4. Check your previous responses from the conversation history section and don't repeat the same sentences in your new responses. It will make users to lose interest.
                    Guidelines for interaction:

                    1. Always maintain a polite and friendly tone.

                    2. Use the restaurant information provided to accurately
                    answer questions.

                    3. If you don't have specific information, politely inform
                    the caller and offer to find out or connect them with
                    someone who can help.

                    4. For reservations, always confirm the date, time, number
                    of guests, and any special requirements.

                    5. When sharing menu information, be prepared to describe
                    dishes, answer questions about ingredients, and mention any
                    daily specials.

                    6. For event bookings, gather all necessary details
                    including the type of event, number of guests, preferred
                    date and time, and any specific requirements.

                    7. When handling food orders, confirm each item, ask about
                    any customizations or dietary restrictions, and provide
                    clear information about delivery times or pickup options.

                    8. For special requests, listen carefully and try to
                    accommodate if possible. If a request can't be fulfilled,
                    offer alternatives.

                    Handling objections and special situations:

                    1. If a desired reservation time is not available, offer
                    alternative times or dates.

                    2. If a menu item is unavailable, apologize and suggest
                    similar dishes.

                    3. If there's a complaint, listen empathetically, apologize
                    sincerely, and offer to address the issue or connect the
                    caller with a manager if necessary.

                    4. For any request you can't fulfill immediately, offer to
                    take a message or have someone call back with more
                    information.

                    Remember to respond naturally, as if you were a human
                    receptionist. Avoid using robotic or overly formal language.
                    Use conversational phrases and show empathy where
                    appropriate.
                                Your conversation can be in one of these stages in no particular order
                                # START OF STAGE DETAILS
                                {sequences}
                                # END OF STAGE DETAILS
                                Respond according to the stage of the conversation you are at. Dont use emojis or any emoticons in your response as your service is going to be rendered as a speech from a text-to-speech service.
                                This is your current conversation history with user, use this conversation history while generating response
                                # START OF CONVERSATION HISTORY
                                {conversation_history}
                                # END OF CONVERSATION HISTORY
                                Also these CONTEXT contains relevant information to answer user's query. Use this context to generate response
                                # START OF CONTEXT
                                {context}
                                # END OF CONTEXT
                    "Do not mention the price unless the caller asks"

                    "If the customer/caller asks, are these vegan dishes?
                    respond, yes we do have vegan options"
                                Keep your responses always in the context of sales and support for the {company_name}.
                                Convey a confident tone, using direct and decisive language.
                                IMPORTANT: End each response with a probing question or a prompt that directs the user towards one of your objectives. Keep your responses in two or fewer short sentences.
                                Example Endings:
                                "Would you like to proceed with a table reservation?"
                                "Shall I go ahead and place that order for you?"
                                "Is there anything else you'd like to know about our services?"
                                Now, generate a response for the user question: {question}
                    Be polite and respectful while keeping the tone of the
                    conversation professional. Your greeting should be
                    welcoming. Always clarify in your greeting the reason why
                    you are calling
                     Needs analysis: Ask open-ended questions to understand whether its a table reservation or order booking or general enquiry of the hotel. Listen carefully. Don't over-confirm or clarify else the caller will be frustrated and cut the call.
                     Solution presentation: Based on the needs of the request, present your solution which also adheres to your responsibilities.
                     End conversation: Thank the customer for their time and confirm the next steps.
                    Also, before ending the call mention "you will receive a
                    confirmation text shortly for your table reservation or food
                    delivery" as applicable. If there are no more additional
                    requests, say bye and end the call.
                  greeting: >-
                    Hi, thanks for calling the Restaurant. I am Sophia, the
                    Restaurant manager powered by AI, how may I assist you
                    today?
                  farewell: Thanks for calling us, you have a great one! Bye
                role: Restuarant Receptionist
                roleDescription: >-
                  As a Restaurant Receptionist, your primary roles are as
                  follows:

                  1. Table Reservation by the guests - you are responsible for
                  taking table reservation requests which involves asking guests
                  or customers for their preferred date and time for visiting
                  the restaurant, along with the total number of guests
                  accompanying for the table reservation. During the call,
                  confirm the reservation. Upon confirmation, convey that the
                  table is reserved for the specific date and time and the
                  number of guests. Ask the guest, if they have any more
                  questions or requests, if not, then politely thank them for
                  considering the restaurant and we are forward to welcoming
                  you. If a table is unavailable or the restaurant is full
                  during the requested date/time/number of guests, then politely
                  convey the guest/customer the status and check if the guest
                  will be ok to reserve another available slot.

                  2. Entertaining any food order for pickup or food delivery by
                  the guests - you are responsible for taking the food order
                  concerning to the restaurant and the menu items available in
                  the context, either a pickup or delivery request. Each menu
                  item/dish has a name and price or cost associated with it. You
                  always have to refer to these menu items/dishes and their
                  prices while taking the order request. You can entertain any
                  special requests only if that context is provided by the
                  restaurant.

                  Following are the steps to be followed for taking the food
                  order either for pickup or delivery:

                  Let the customer select the dish/item, if the selected
                  dish/item has a variation like size or quantity, reconfirm
                  with the guest/customer. Only add items to order as per
                  customers choice. Reconfirm the ordered menu item share the
                  itemized price and then move ahead.

                  You have to reconfirm each menu dish/item along with its price
                  & requested quantity for order confirmation. Ensure you share
                  the itemized value and also the total order value.

                  You have to share the total order value by adding the value of
                  each item and quantity requested by the customer/guest. Don’t
                  add any more cost to the item price or total order value as
                  all the items are inclusive of taxes. If any exceptions with
                  price, the context will be provided by the restaurant.

                  Ensure to reconfirm the entire order including quantity,
                  price, menu item, and special request(if any) made by the
                  customer before placing the order in the system. Ask if they
                  need to add anything else, if yes, just add any additional
                  items in addition to the existing order.

                  For order pickup, request the customer/quest for their name,
                  and phone number for confirmation. If the customer already
                  provided their name, and phone number at the start of the
                  call, reconfirm the same details. Upon confirmation, mention
                  the order will be ready in the next 30-45mins.

                  For food delivery, request the customer/quest for their name,
                  phone number, and delivery address for confirmation. If the
                  customer already provided their name, phone number, and
                  delivery address at the start of the call, reconfirm the same
                  details. Upon confirmation, mention the order will be
                  delivered in the next 45 minutes - 1 hour.

                  3. Entertaining any special requests by the guests - if there
                  are any special requests like specific seating arrangements,
                  meal preparation process, etc, the respective context will be
                  provided by the restaurant beforehand. If no context, politely
                  mention that you need to check internally and revert asap.

                  4. Sharing menu items, day or week specials, offers, chef or
                  restaurant specials if requested by the guests - apart from
                  the menu request by the customer, proactively share any
                  offers, daily or weekly specialties (if any). The restaurant
                  will provide details and context.

                  5. Taking any custom inquiry or celebration or corporate
                  events or party arrangements by the guests - entertain any
                  custom planning or celebrations or corporate events or
                  arrangements by the guests. The restaurant will provide
                  details and context.

                  6. General Information sharing about the restaurant, food,
                  preparation style, menu options, seating arrangements or
                  capacity, rush hours, and timings. The restaurant will provide
                  details and context.

                  7. Transfer the call to a human or arrange a call back if the
                  guest's request is unique or if they ask to speak to a human
                  or manager of the restaurant. Respond with a call-back option
                  within 30 mins.
                voice:
                  gender: Female
                  languageAccent:
                    language: English
                    accent: Indian
                  modelId: voi.1729331556.dtKoZ0k5
                status: active
                timezone: Asia/Calcutta
                createdBy: org.1726902940.GZChqlpU
                createdAt: '2024-09-21T07:18:52.955359'
                updatedBy: k5NA7lbjreQglMmOBTVzBh3rFyU2
                updatedAt: '2024-10-25T05:47:29.458315'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    AIAgent-Input:
      properties:
        name:
          type: string
          maxLength: 512
          minLength: 1
          title: Name
          description: Name of the AI agent
          example: HelperBot
        imageUrl:
          type: string
          maxLength: 512
          minLength: 1
          title: Imageurl
          description: Image URL for the AI agent
          example: http://example.com/agent.png
        mission:
          anyOf:
            - $ref: '#/components/schemas/Mission'
            - type: 'null'
          description: Mission of the AI agent
        status:
          allOf:
            - $ref: '#/components/schemas/Status'
          description: Status of the AI agent
        role:
          type: string
          maxLength: 512
          minLength: 1
          title: Role
          description: Role of the AI agent in the company
          example: Customer Support
        roleDescription:
          type: string
          minLength: 1
          title: Roledescription
          description: Description of the role of the AI agent
          example: Handles customer inquiries and support tasks
        timezone:
          type: string
          maxLength: 512
          minLength: 1
          title: Timezone
          description: Timezone of the AI agent used for scheduling meetings
          example: America/New_York
        voice:
          anyOf:
            - $ref: '#/components/schemas/Voice-Input'
            - type: 'null'
          description: Voice of the AI agent
      type: object
      required:
        - name
        - imageUrl
        - status
        - role
        - roleDescription
        - timezone
      title: AIAgent
    AIAgent-Output:
      properties:
        id:
          type: string
          title: Id
        orgId:
          type: string
          title: Orgid
        name:
          type: string
          title: Name
        imageUrl:
          type: string
          title: Imageurl
        mission:
          anyOf:
            - $ref: '#/components/schemas/Mission'
            - type: 'null'
        role:
          type: string
          title: Role
        roleDescription:
          type: string
          title: Roledescription
        transcriber:
          anyOf:
            - $ref: '#/components/schemas/Transcriber'
            - type: 'null'
        intelligenceProvider:
          anyOf:
            - $ref: '#/components/schemas/IntelligenceProvider'
            - type: 'null'
        voice:
          anyOf:
            - $ref: '#/components/schemas/Voice-Output'
            - type: 'null'
        status:
          type: string
          title: Status
        timezone:
          type: string
          title: Timezone
        createdBy:
          type: string
          title: Createdby
        createdAt:
          type: string
          format: date-time
          title: Createdat
        updatedBy:
          type: string
          title: Updatedby
        updatedAt:
          type: string
          format: date-time
          title: Updatedat
      type: object
      title: AIAgent
      description: AI agent configured by businesses
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Mission:
      properties:
        prompt:
          anyOf:
            - type: string
              minLength: 1
            - type: 'null'
          title: Prompt
          description: Full prompt instructions for LLM model
          example: Check Trata AI docs on the specifics of prompting.
        objective:
          anyOf:
            - type: string
              maxLength: 1024
              minLength: 1
            - type: 'null'
          title: Objective
          description: Objective of the mission
          example: >-
            This is a more easier version where the user dont have to given the
            entire prompt but just share the objective of the call and rest will
            be handled by Trata.
        greeting:
          anyOf:
            - type: string
              maxLength: 1024
              minLength: 1
            - type: 'null'
          title: Greeting
          description: Greeting message to be read by the AI agent
          example: Hello! Thank you for taking the time to speak with me today.
        sequence:
          anyOf:
            - items:
                $ref: '#/components/schemas/Sequence'
              type: array
            - type: 'null'
          title: Sequence
          description: >-
            Sequence of actions to be performed by the AI agent during the
            conversation.
        farewell:
          anyOf:
            - type: string
              maxLength: 1024
              minLength: 1
            - type: 'null'
          title: Farewell
          description: Conclusion message to be read by the AI agent
      type: object
      required:
        - greeting
      title: Mission
    Status:
      type: string
      enum:
        - active
        - inactive
      title: Status
    Voice-Input:
      properties:
        gender:
          type: string
          enum:
            - Male
            - Female
            - Neutral
          title: Gender
        languageAccent:
          $ref: '#/components/schemas/LanguageAccentCombo'
        modelId:
          type: string
          title: Modelid
      type: object
      required:
        - gender
        - languageAccent
        - modelId
      title: Voice
    Transcriber:
      properties:
        providerName:
          type: string
          title: Providername
        transcriberModel:
          anyOf:
            - type: string
            - type: 'null'
          title: Transcribermodel
        providerProps:
          anyOf:
            - type: object
            - type: 'null'
          title: Providerprops
      type: object
      title: Transcriber
    IntelligenceProvider:
      properties:
        providerName:
          anyOf:
            - type: string
            - type: 'null'
          title: Providername
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
        providerProps:
          anyOf:
            - type: object
            - type: 'null'
          title: Providerprops
      type: object
      title: IntelligenceProvider
    Voice-Output:
      properties:
        gender:
          type: string
          enum:
            - Male
            - Female
            - Neutral
          title: Gender
        languageAccent:
          $ref: '#/components/schemas/LanguageAccentCombo'
        modelId:
          type: string
          title: Modelid
      type: object
      required:
        - gender
        - languageAccent
        - modelId
      title: Voice
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    Sequence:
      properties:
        stageName:
          type: string
          maxLength: 1024
          minLength: 1
          title: Stagename
          description: Name of the stage
          example: Introduction
        description:
          type: string
          maxLength: 4096
          minLength: 1
          title: Description
          description: Description of the stage
          example: >-
            This stage involves introducing the AI agent to the user and
            explaining the purpose of the call.
        otherNotes:
          anyOf:
            - type: string
              maxLength: 4096
              minLength: 1
            - type: 'null'
          title: Othernotes
          description: Other notes that AI agent should know in this stage of conversation
          example: Ensure the user understands the privacy policy.
      type: object
      required:
        - stageName
        - description
      title: Sequence
    LanguageAccentCombo:
      properties:
        language:
          $ref: '#/components/schemas/Language'
        accent:
          $ref: '#/components/schemas/Accent'
      type: object
      required:
        - language
        - accent
      title: LanguageAccentCombo
    Language:
      type: string
      enum:
        - English
        - Spanish
        - Hindi
      title: Language
    Accent:
      type: string
      enum:
        - American
        - Indian
        - Australian
        - British
        - Hindi
      title: Accent
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````