Category: Chat

  • AI chatbots can serve as effective study partners?

    Do you think AI chatbots can serve as effective study partners?

    View Poll

    submitted by /u/Build_Chatbot
    [link] [comments]

  • AI chatbot for educational assistance

    Have you ever used an AI chatbot for educational assistance or support?

    View Poll

    submitted by /u/Build_Chatbot
    [link] [comments]

  • Embedding LLM with custom character profile via iframe/JS on webpage?

    for reference, I’m a creative writer working on a project. I recently had an idea of integrating a very specific character AI profile into a webpage article as a dedicated companion character (like a friendly AI helper or something) that a reader could submit questions to or speak with. I was wondering if it were possible to embed a character AI profile using an iframe or related JS (this will be done on a Wikidot page, if anyone happens to be familiar with that website lol). I’m not very educated on the specifics but I’d be more than happy to learn if I know it’s feasible. I’m not sure what tools are available but I know that I’ll likely need to host my own HTML page for an iframe or somehow construct my own JS module with a separate Wikidot page and somehow protect my API key but I didn’t know who else to go to since I lack the proper knowledge with interfacing with LLMs or AI in general beyond some testing with Character AI and Silly Tavern.

    Any help would be appreciated!

    submitted by /u/JakdragonX
    [link] [comments]

  • AI Chabot with Maximum File format support for adding Knowledgebase with Live Chat using Slack

    Our AI Chatbot Build Chatbot AI an Chatbot that supports the maximum type of File formats – Website URL, You tube, Audio, Video, PDF, Docx, TXT and Excel. The Chatbot can be personalized to your branding for a chat widget or a chatbot within a web page. You can also live chat with users with Slack integration right from your slack channels.

    The Chatbot can work both as an AI and also options to live chat.

    Freemium version available to try!

    submitted by /u/Playful-Analyst6425
    [link] [comments]

  • Top 10 Powerful Use Cases of Generative AI Chatbots in Call Centers

    In the rapidly evolving landscape of customer service, call centers are embracing cutting-edge technologies to elevate their operations and meet the growing expectations of today’s consumers. Among these transformative technologies, Generative AI chatbots have emerged as a game-changer. These intelligent virtual assistants are modifying the way call centers engage with customers, streamline processes, and deliver exceptional experiences. In this article, we delve into the diverse use cases of Generative AI chatbots in call centers, uncovering their potential to optimize customer support, improve efficiency, and drive business success. We explore the transformative impact of Generative AI chatbots in enhancing customer experiences within call center environments.

    According to a recent study conducted by researchers from Stanford Digital Economy Laboratory and MIT Sloan School of Management, the implementation of a Generative AI assistant tool in call centers led to a significant increase in productivity. The study revealed an average productivity boost of 13.8%, measured by the number of customer issues resolved per hour. These findings shed light on the influence of Generative AI in workplace settings, particularly in the customer service sector, which has already embraced AI technology at a substantial rate.

    Based on Gartner’s prediction in August 2022, the implementation of conversational AI chatbots in contact centers is projected to result in a remarkable $80 billion reduction in customer service labor costs by 2026. While the use of Generative AI in call centers is still in its early stages, it is worthwhile to explore some of the potential use cases for Generative AI chatbots in this context.

    Generative AI Chatbot Use Cases for Call Centers

    Generative AI Chatbot Use Cases for Call Centers

    Generative AI Chatbot Use Case for Call Centers #1. Improving Customer Support

    Customer Support is one of the primary use cases for Generative AI chatbots in call centers. These chatbots are capable of handling routine customer inquiries, such as providing product information, assisting with order tracking, or offering basic troubleshooting guidance. By leveraging the power of Generative AI, these chatbots can generate instant responses to customer queries, eliminating the need for customers to wait in lengthy phone queues or navigate complex Interactive Voice Response (IVR) systems.

    Generative AI chatbots excel at understanding natural language and can interpret customer requests accurately. They can analyze the input from customers, identify the intent behind their queries, and generate appropriate responses based on the available information. This ability enables them to provide quick and accurate support to customers.

    Generative AI chatbots can also assist with basic troubleshooting. They can guide customers through step-by-step instructions or provide interactive tutorials to help them resolve common issues on their own. This self-service capability not only empowers customers but also reduces the need for human agent intervention, leading to increased efficiency and cost savings for the call center.

    Thinking of incorporating Generative AI into your chatbot? Validate your idea with a Proof of Concept before launching. At Master of Code Global, we can seamlessly integrate Generative AI into your current chatbot, train it, and have it ready for you in just two weeks.

    REQUEST POC

    Generative AI Chatbot Use Case for Call Centers #2. Frequently Asked Questions (FAQs) Automation

    Generative AI chatbots can be highly effective in handling frequently asked questions (FAQs) in call centers. By training the chatbot with an extensive database of commonly asked questions and their corresponding answers, call centers can provide customers with instant and accurate responses without the need for human intervention.

    For example, a customer contacts a call center with a common question about a product return policy. Here’s an example to illustrate the use case.

    FAQs Automation with Generative AI Chatbot

    In this example, the Generative AI chatbot recognizes the customer’s query regarding the return policy and provides a prompt and accurate response. The chatbot offers further assistance by proactively offering more information and guidance on the return process. By efficiently addressing the customer’s concern, the chatbot eliminates the need for the customer to wait on hold or be transferred to a human agent, saving time for both the customer and the call center.

    Generative AI chatbots excel in this use case by leveraging their ability to quickly search through a vast FAQ knowledge base and retrieve the relevant information. This empowers call centers to provide consistent and reliable responses to customers, ensuring a positive customer experience.

    Generative AI Chatbot Use Case for Call Centers #3. Order Processing

    Generative AI chatbots can play a valuable role in facilitating order processing in call centers. They can assist customers with various aspects of the order management process, including placing orders, checking order status, and making modifications. By integrating with backend systems, such as inventory management and order fulfillment systems, chatbots can streamline the order process and provide real-time updates to customers, ensuring a seamless and efficient experience.

    Generative AI Chatbot Use Case for Call Centers #4. ACW Documentation

    Automated documentation is a key use of Generative AI in post-call tasks. Generative AI can be trained to listen to a call, comprehend the context, and generate a concise summary of the conversation. This summary can be automatically added to the customer’s record, reducing the manual effort needed from agents. This reduces after-call work (ACW) time and ensures accurate and consistently formatted records, minimizing potential errors from manual data entry.

    During a No Jitter webinar sponsored by Five9, Richard Dumas from Five9 discussed a specific application in the call center system. In this use case, the system generates a transcript of a customer call and subsequently utilizes GPT-3, a prominent large language model (LLM) predating GPT-4, to analyze the transcript.

    In this particular scenario, the system instructs GPT-3 to summarize the call and highlight essential details gathered by the agent, such as the customer’s name, address, and mentioned products. The agent has the option to review, edit, or approve the generated summary. Real-time transcription frees agents from the responsibility of note-taking, allowing them to focus their attention on customers and engage in more meaningful interactions. Furthermore, the automatic synchronization of consistent and precise call summaries with the customer relationship management (CRM) system substantially decreases the amount of after-call work needed.

    ACW Documentation Automatization with Generative AI

    Analyst Dave Michels from TalkingPointz mentioned that, based on his observations, the large language model (LLM) excels at summarization and efficiently captures the important points of a conversation. Michels emphasized that leveraging Generative AI for agent wrap-up in call centers can result in significant time savings. Richard Dumas further highlighted that even a one-minute reduction from a five-minute call can translate to a substantial 20% cost savings for the call center.

    Check out your potential cost savings by implementing a chatbot solution for customer support

    CALCULATE ROI

    Generative AI Chatbot Use Case for Call Centers #5. Post-Interaction Tasks

    Generative AI chatbots provide the capability for proactive follow-up actions in call centers. For example, when a customer contacts the call center regarding a faulty product, the AI system can automatically generate an email to the customer containing detailed information about the return process. In more advanced cases, the Generative AI chatbot can even initiate a return request on behalf of the customer, streamlining the process and providing a higher level of convenience. This proactive approach saves time for both the customer and the call center, ensuring that necessary actions are taken promptly and efficiently.

    Generative AI Chatbot Use Case for Call Centers #6. Training Call Center Agents

    Generative AI chatbots can play a vital role in training and developing call center agents. By harnessing their capabilities, call centers can create immersive training experiences that allow agents to practice and refine their skills. Additionally, Generative AI chatbots can generate simulated after-call work scenarios, replicating the tasks agents typically perform after completing a call, such as documenting call details, updating customer records, or scheduling follow-ups.

    By analyzing the interactions between agents and Generative AI chatbots, supervisors and trainers can identify strengths and weaknesses in agent performance. They can thoroughly review the summaries and actions generated by chatbots, assessing the quality of responses, adherence to guidelines, and compliance with policies. This comprehensive analysis enables targeted coaching and training to address specific areas for improvement, leading to increased agent performance and customer satisfaction.

    Generative AI Chatbot Use Case for Call Centers #7. Feedback and Surveys

    Generative AI chatbots in call centers have the capability to gather valuable insights through proactive feedback and surveys after customer interactions. These chatbots can initiate conversations to request feedback or administer short surveys, providing an easy and convenient way for customers to share their thoughts and opinions. The collected data can be used to measure customer satisfaction, identify areas for improvement, and generate actionable analytics reports. This enables call centers to continuously enhance their services and deliver an exceptional customer experience.

    Generative AI Chatbot Use Case for Call Centers #8. Troubleshooting and Technical Support

    Generative AI chatbots in call centers excel at providing efficient troubleshooting and technical support to customers. They have the ability to guide customers through basic troubleshooting steps for common technical issues. By offering step-by-step instructions or interactive tutorials, chatbots empower customers to resolve problems independently, without requiring assistance from a live agent. This not only saves time for both customers and call center agents but also raises the overall customer experience by enabling quick issue resolution.

    Generative AI Chatbot Use Case for Call Centers #9. Appointment Scheduling

    Generative AI chatbots offer a seamless solution for customers looking to schedule appointments, whether it’s for service requests or consultations. These chatbots have the ability to access the availability of agents or resources, providing customers with real-time information on open time slots. By facilitating the booking process without the need for human intervention, Generative AI chatbots streamline appointment scheduling, saving time for both customers and call center staff. This automation ensures efficient and hassle-free booking, enhancing customer satisfaction and optimizing resource utilization. Over the past year, we’ve helped our clients invest in Conversational AI solution and increased 7.67x weekly bookings or conversion rate 3x higher since the chatbot was launched.

    Generative AI Chatbot Use Case for Call Centers #10. Multilingual Support

    Generative AI chatbots possess the remarkable ability to communicate fluently in multiple languages, making them a valuable asset for call centers serving diverse customer bases. With this capability, call centers can cater to customers from different linguistic backgrounds without the need for language-specific agents. The multilingual customer support provided by Generative AI chatbots enhances accessibility and inclusivity, allowing customers to interact comfortably in their preferred language. By overcoming language barriers, call centers can improve customer satisfaction, ensure effective communication, and provide a seamless experience to customers worldwide.

    Multilingual Support with Generative AI Chatbot

    Call center platforms such as Yobi leverage Generative AI to perform sentiment analysis, allowing contact center agents to evaluate customers’ emotional states by analyzing their tone of voice and choice of words. Yobi, an assistant powered by Generative AI, signifies the future of business communications. It enhances Sales, Marketing with Generative AI, and Customer Contact teams, enabling seamless communication with prospects and customers through diverse channels like Facebook Messenger, Twitter, SMS, Zendesk, and other platforms. This Generative AI-powered assistant offers a range of incredible advantages, including translation and snippet features, that significantly simplify various tasks and raise efficiency.

    Benefits of Generative AI Chatbot for Call Centers

    Benefits of Generative AI Chatbot for Call Centers
    • Raised Efficiency and Productivity: Integrating Generative AI chatbots into call centers can significantly improve efficiency and productivity. These intelligent assistants can handle routine customer inquiries, reducing the workload on human agents and allowing them to focus on more complex and high-value tasks. By automating repetitive tasks, companies can streamline their operations and achieve higher productivity levels.
    • Scalability: Generative AI chatbots offer scalability, allowing businesses to handle increasing customer demands without the need to hire and train additional human agents. As customer volumes fluctuate, chatbots can seamlessly handle the increased workload, ensuring a consistent level of service without compromising quality or efficiency. This scalability is particularly beneficial during peak periods or when expanding into new markets.
    • Enhanced Customer Service: Generative AI chatbots can provide instant responses and accurate information to customers, leading to improved customer service. Customers receive prompt assistance, even outside regular working hours, ensuring their needs are addressed in a timely manner. This enhanced level of service contributes to higher customer satisfaction, loyalty, and positive brand perception.
    • Cost Savings: Incorporating Generative AI chatbots into call centers can result in significant cost savings for companies. By automating customer interactions, companies can reduce the need for a large workforce of human agents, leading to lower staffing and training costs. Additionally, chatbots can handle a high volume of inquiries simultaneously, further reducing operational expenses. These cost savings can contribute to improved profitability and a more efficient use of resources within the organization.
    • 24/7 Availability: Generative AI chatbots can provide round-the-clock customer support, ensuring that assistance is available at any time of the day or night. This 24/7 availability is particularly beneficial for companies operating in different time zones or those serving a global customer base. Customers can receive support and information whenever they need it, improving their overall experience and reducing the reliance on traditional working hours.
    • Data-Driven Insights: Generative AI chatbots have the ability to gather valuable data and insights from customer interactions. Business owners can leverage this data to gain a deeper understanding of customer preferences, pain points, and trends. These valuable insights can inform strategic decision-making, including refining products and services, personalizing marketing efforts, and identifying areas for improvement. By utilizing this data, business owners can make informed, data-driven decisions that ultimately lead to business growth.

    Conclusion

    Generative AI chatbots have emerged as a powerful tool for call centers, revolutionizing customer service and enhancing overall business operations. These intelligent chatbots enable proactive follow-up actions, streamline processes, provide multilingual support, and gather valuable data and insights. By integrating Generative AI chatbots into their call centers, businesses can automate customer interactions, improve efficiency, reduce costs, and improve customer satisfaction. The future holds even more possibilities for AI in call centers, promising further advancements and innovations. Embracing Generative AI chatbots is a strategic move that empowers businesses to deliver exceptional customer service, build meaningful relationships, and drive sustainable growth in today’s competitive market.

    Request a Demo

    Don’t miss out on the opportunity to see how Generative AI chatbots can revolutionize your customer support and boost your company’s efficiency.


    Top 10 Powerful Use Cases of Generative AI Chatbots in Call Centers was originally published in Chatbots Life on Medium, where people are continuing the conversation by highlighting and responding to this story.

  • Appointment Booking Chatbot using OpenAI Function Calling and GoHighLevel Calendar

    OpenAI has recently launched a range of remarkable enhancements that have left users amazed. Among these additions, the OpenAI function calling feature has emerged as the most prominent addition. With this powerful functionality, developers gain the ability to select and invoke for resolving specific problems. A key aspect of OpenAI’s function calling feature is its seamless integration with external APIs, enabling developers to generate responses by leveraging external services.

    In our previous blogs, we explored “How To Use OpenAI Function Calling To Create an Appointment Booking Chatbot”. Through this exploration, we created a chatbot that integrates with the Google Calendar API. This integration empowers the chatbot to efficiently handle appointment bookings and harness the full functionality of the Google calendar.

    In this blog, we will explore how to create an appointment-booking chatbot, which integrates with the GoHighLevel platform for appointment management. GoHighLevel is a customer relationship management (CRM) platform that offers various features for businesses to manage their customer interactions, marketing campaigns, sales processes, and more. One of the features provided by GoHighLevel is the calendar functionality. The GoHighLevel calendar allows users to schedule and manage appointments and delete appointments.

    Let’s start with the blog where we will explore how to create an appointment booking chatbot that seamlessly integrates with the GoHighLevel (GHL) platform.

    Step 1:

    We will start by setting up the GoHighLevel platform. We need to first go to the https://app.gohighlevel.com/ website and then claim our free 14-day trial. You need to give your Company Name, Name, Email ID, Phone number, and credit card details to sign up for the first time.

    Once you have created an account, you will see below like dashboard:

    Step 2:

    We need to use GoHighLevel API, to manage appointment creation, updation, and deletion. In order to use the API, we need an API key.

    There are 2 types of API keys available:

    • Agency API Key — which is used to manage the agency-level objects like sub-accounts, and users.
    • Location API Key — which is used to manage all the objects which are part of sub-accounts (contacts, appointments, opportunities, etc.)

    To manage appointments we need a Location API key. To generate a Location API key you need to first add a location by creating a sub-account.

    To create a sub-account you need to first click the “Sub-Accounts” from the left panel and then hit “Create Sub-Account” as shown below:

    Step 3:

    It will open a screen like below, where you need to select “Blank Snapshot” under the title “Regular Account”.

    Then, it will open a screen with a map like below. You need to select your location and then continue with your selected location by clicking the arrow.

    After this, it will open a tab with the title “Add account”. You need to add your details and then hit the “save” button. It will create a sub-account with the given location.

    Step 4:

    Next, You need to switch to the recently created sub-account by clicking on “Click here to switch” from the left panel as shown in the below image:

    It will open up a selection box that has all sub-accounts listed. You can choose one from the list, and the system will switch to that account. and then you can see a screen like below:

    Step 5:

    After creating a sub-account, you can retrieve the Location API key, which will be used for appointment management. To obtain the Location API key, first go to the “Settings” option located in the left panel and then select “Business Profile” from the available options. A screen will appear where you need to scroll down a bit, and you will find your Location API key as shown in the below image:

    Step 6:

    Moving forward, we need to add employees to our team. To add an employee, you need to follow the below steps:

    • First, you need to go to the setting and then select the “My Staff” option from all available options.
    • On the screen that appears, locate and click on the “Add employee” button.
    • Provide the necessary personal details, including First Name, Last Name, Email, Password, and Phone Number.
    • Next, set the “User Roles” to “User” for the employee.
    • Finally, click on the “Save” button to save the employee’s information.

    Step 7:

    Now, let’s proceed with creating a group that will help in team management. To create the group, you need to follow below steps:

    • Start by selecting the “Calendars” option from the left panel.
    • On the right side of the screen, locate and click on the “Create Group” button.
    • It will open up a form for group creation. In the form, you will need to provide the following details: Group Name, Group Description, and Calendar URL.
    • Once you have filled in the necessary information, submit the form.

    In the Calendar URL, you can simply provide any string like “demo-calendar”.

    Step 8:

    Let’s now move forward and create a calendar that will facilitate appointment management functions. To create the calendar, follow the below steps:

    • From the same screen, select the “Create Calendar” option.
    • This action will open up a list of options. From the list, choose “Simple Calendar”.
    • A form will appear, in which you need to fill in all the necessary details.
    • Once you have filled in the necessary details, click on the “Complete” button.

    For this demo, we have kept the “Appointment Slot Setting” as below:

    Step 9:

    Once you have created a calendar, the next step is to move it to the previously created group. To accomplish this, follow the steps below:

    • Select the “Calendars” option from the settings.
    • On the screen, locate the calendar that was created earlier.
    • Click on the three dots symbol situated on the right side of the calendar.
    • This action will open up a selection box, as depicted below.
    • From the selection box, choose the option “Move to Group”.
    • A pop-up box will appear, allowing you to select the desired group for the calendar and hit the “Select” button.

    Step 10:

    We have completed the basic setup of “GoHighLevel.” Now, we are fully prepared to utilize the GoHighLevel API for appointment creation, updating, and deletion. To use the GoHighLevel API, we need three types of IDs: Group ID, Calendar ID and User ID. We will obtain these IDs in the following steps.

    To obtain the Group ID, you need to follow the below steps:

    • Select the “Calendars” option from the settings.
    • On the screen, You will find a tab for “Groups” in which you will locate the group that was created earlier.
    • Click on the three dots symbol situated on the right side of the group information.
    • This action will open up a selection box, as depicted below.
    • Click on the “Copy Embed Code” from the selection box.

    Your copied embed code will look like below:

    <iframe src=”https://api.leadconnectorhq.com/widget/group/NZc2nxIeE6a2liSwqmNX” style=”width: 100%;border:none;overflow: hidden;” scrolling=”no” id=”<your_group_id>_1688194531391″></iframe><br><script src=”https://link.msgsndr.com/js/form_embed.js” type=”text/javascript”></script>

    From the URL above, you can locate the ID field. The string before the “_” symbol represents your Group ID.

    Step 11:

    Moving forward in this step, we will obtain our Calendar ID.

    To obtain the Calendar ID, you need to follow the below steps:

    • Select the “Calendars” option from the settings.
    • On the screen, You will find a tab for “Calendars” in which you will locate the calendar that was created earlier.
    • Click on the three dots symbol situated on the right side of the calendar information.
    • This action will open up a selection box, as depicted below.
    • Click on the “Copy Embed Code” from the selection box.

    Your copied embed code will look like below as earlier:

    <iframe src=”https://api.leadconnectorhq.com/widget/booking/kK8LwFPuNByksXB3h18s” style=”width: 100%;border:none;overflow: hidden;” scrolling=”no” id=”<your_calendar_id>_1688196021697″></iframe><br><script src=”https://link.msgsndr.com/js/form_embed.js” type=”text/javascript”></script>

    Step 12:

    In this step, let’s proceed to obtain the User ID.

    To obtain the User ID, you need to follow the below steps:

    After completion of these steps, we have all 3 IDs, now we will move forward to secret an appointment booking chatbot using python.

    Step 13:

    Now, it’s time to start with the development of the Python script for an appointment booking chatbot. To accomplish this, we will leverage OpenAI’s function calling feature, which integrates with the GHL Calendar for efficient appointment management.

    First, we will import the required libraries:

    import requests
    import json
    from datetime import date, datetime, timedelta
    import time
    import pytz

    Step 14:

    Next, we will define a utility function that will call ChatGPT and generate responses. To add this functionality to our script, include the following lines of code:

    GPT_MODEL = "gpt-3.5-turbo-0613"
    openai_api_key = "<your_openai_key>"

    def chat_completion_request(messages, functions=None, function_call=None, model=GPT_MODEL):
    headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer " + openai_api_key,
    }
    json_data = {"model": model, "messages": messages}
    if functions is not None:
    json_data.update({"functions": functions})
    if function_call is not None:
    json_data.update({"function_call": function_call})
    try:
    response = requests.post(
    "https://api.openai.com/v1/chat/completions",
    headers=headers,
    json=json_data,
    )
    return response
    except Exception as e:
    print("Unable to generate ChatCompletion response")
    print(f"Exception: {e}")
    return e

    Step 15:

    Moving forward, in this step, we will define a function that calls the GHL appointment booking endpoint. However, before that, we need to create another function that converts the date and time provided by the user into the ISO 8601 date format. The ISO 8601 format is an internationally recognized standard for representing dates and times.

    We can define both functions as follows:

    limit1 = datetime.strptime("10:00:00", "%H:%M:%S").time()
    limit2 = datetime.strptime("17:00:00", "%H:%M:%S").time()
    limit3 = datetime.strptime("12:00:00", "%H:%M:%S").time()

    headers = {
    'Authorization': 'Bearer <Your_Location_API_key>'
    }

    def convert_to_iso8601(datetime_string, target_timezone):
    datetime_format = "%Y-%m-%d %H:%M:%S"
    dt = datetime.strptime(datetime_string, datetime_format)

    source_timezone = pytz.timezone('Asia/Kolkata')
    dt = source_timezone.localize(dt)

    target_timezone = pytz.timezone(target_timezone)
    dt = dt.astimezone(target_timezone)

    iso8601_datetime = dt.strftime("%Y-%m-%dT%H:%M:%S%z")
    iso8601_datetime = iso8601_datetime[:-2] + ":" + iso8601_datetime[-2:]
    return iso8601_datetime

    def appointment_booking(arguments):
    try:
    provided_date = datetime.strptime(json.loads(arguments)['date'], "%Y-%m-%d")
    provided_time = datetime.strptime(json.loads(arguments)['time'].replace("PM","").replace("AM","").strip(), "%H:%M:%S").time()
    try:
    email_address = json.loads(arguments)['email_address']
    except:
    return "Please provide email ID for identification."

    try:
    phone_number = json.loads(arguments)['phone_number']
    except:
    return "Please provide a phone number for identification."

    if provided_date and provided_time and email_address and phone_number:
    start_date_time = str(provided_date.date()) + " " + str(provided_time)
    iso8601_datetime = convert_to_iso8601(start_date_time, 'Asia/Kolkata')

    if day_list[provided_date.weekday()] == "Saturday":
    if provided_time >= limit1 and provided_time <= limit3:
    url = "https://rest.gohighlevel.com/v1/appointments/"
    payload = {
    "calendarId": "kK8LwFPuNByksXB3h18s",
    "selectedTimezone": "Asia/Calcutta",
    "selectedSlot": iso8601_datetime,
    "email": email_address,
    "phone": phone_number
    }
    response = requests.request("POST", url, headers=headers, data=payload)
    response = json.loads(response.text)
    try:
    if response['id']:
    return "Appointment booked successfully."
    except:
    return response['selectedSlot']['message']
    else:
    return "Please try to book an appointment into working hours, which is 10 AM to 2 PM at saturday."
    else:
    if provided_time >= limit1 and provided_time <= limit2:
    url = "https://rest.gohighlevel.com/v1/appointments/"
    payload = {
    "calendarId": "kK8LwFPuNByksXB3h18s",
    "selectedTimezone": "Asia/Calcutta",
    "selectedSlot": iso8601_datetime,
    "email": email_address,
    "phone": phone_number
    }
    response = requests.request("POST", url, headers=headers, data=payload)
    response = json.loads(response.text)
    try:
    if response['id']:
    return "Appointment booked successfully."
    except:
    return response['selectedSlot']['message']
    else:
    return "Please try to book an appointment into working hours, which is 10 AM to 7 PM."
    else:
    return "Please provide all the necessary information: Appointment date, time, email ID, Phone number."
    except:
    return "We are facing an error while processing your request. Please try again."

    Step 16:

    Now, let’s define a function that will update appointments using the GHL endpoint. To update an appointment, we need to find the corresponding ‘ID’ of the appointment. Therefore, we will first describe a function that fetches the ‘ID’ based on the parameters provided by the user. This function will then return the ‘ID’ to the update function.

    We can define both functions as follows:

    def get_all_booked_appointment(arguments):
    try:
    provided_date = datetime.strptime(json.loads(arguments)['date'], "%Y-%m-%d")
    ending_date_time = datetime.strptime(json.loads(arguments)['date'], "%Y-%m-%d") + timedelta(days=1)
    try:
    email_address = json.loads(arguments)['email_address']
    except:
    return "Please provide email ID for identification."

    if provided_date and email_address:
    starting_timestamp = time.mktime(provided_date.timetuple()) * 1000
    ending_timestamp = time.mktime(ending_date_time.timetuple()) * 1000


    url = f"https://rest.gohighlevel.com/v1/appointments/?startDate={starting_timestamp}&endDate={ending_timestamp}&userId=oJbRc7r2HBYunuvJ3XC7&calendarId=kK8LwFPuNByksXB3h18s&teamId=ONZc2nxIeE6a2liSwqmNX&includeAll=true"

    payload={}

    response = requests.request("GET", url, headers=headers, data=payload)
    response = json.loads(response.text)
    events = []
    for element in response['appointments']:
    if element['contact']['email'] == email_address:
    events.append(element)

    if len(events) == 1:
    id = events[0]['id']
    return id
    elif len(events) > 1:
    print("You have multiple appointments with the same email address:")
    count = 1
    for ele in events:
    print(str(count)+"]")
    print(ele['address'])
    print(ele['startTime'])
    print(ele['endTime'])
    print(ele['contact']['email'])
    print()
    count = count + 1

    event_number = int(input("Please enter which appointment:"))
    if event_number >= 1 and event_number <= len(events):
    id = events[event_number - 1]['id']
    return id
    else:
    return "Please select valid event number"
    else:
    return "No registered event found with this email ID."
    else:
    return "Please provide all the necessary information: Appointment date and email ID."
    except:
    return "We are facing an error while processing your request. Please try again."

    def appointment_updation(arguments):
    try:
    provided_date = datetime.strptime(json.loads(arguments)['to_date'], "%Y-%m-%d")
    provided_time = datetime.strptime(json.loads(arguments)['time'].replace("PM","").replace("AM","").strip(), "%H:%M:%S").time()

    if provided_date and provided_time and json.loads(arguments)['date'] and json.loads(arguments)['email_address']:
    start_date_time = str(provided_date.date()) + " " + str(provided_time)
    iso8601_datetime = convert_to_iso8601(start_date_time, 'Asia/Kolkata')

    if day_list[provided_date.date().weekday()] == "Saturday":
    if provided_time >= limit1 and provided_time <= limit3:
    id = get_all_booked_appointment(arguments)
    if id == "Please select valid event number" or id == "No registered event found with this email ID." or id == "We are facing an error while processing your request. Please try again.":
    return id
    else:
    url = f"https://rest.gohighlevel.com/v1/appointments/{id}"
    payload = {
    "selectedTimezone": "Asia/Calcutta",
    "selectedSlot": iso8601_datetime
    }
    response = requests.request("PUT", url, headers=headers, data=payload)
    response = json.loads(response.text)
    try:
    if response['id']:
    return "Appointment updated successfully."
    except:
    return response['selectedSlot']['message']
    else:
    return "Please try to book an appointment into working hours, which is 10 AM to 2 PM at saturday."
    else:
    if provided_time >= limit1 and provided_time <= limit2:
    id = get_all_booked_appointment(arguments)
    if id == "Please select valid event number" or id == "No registered event found with this email ID." or id == "We are facing an error while processing your request. Please try again.":
    return id
    else:
    url = f"https://rest.gohighlevel.com/v1/appointments/{id}"
    payload = {
    "selectedTimezone": "Asia/Calcutta",
    "selectedSlot": iso8601_datetime
    }
    response = requests.request("PUT", url, headers=headers, data=payload)
    response = json.loads(response.text)
    try:
    if response['id']:
    return "Appointment updated successfully."
    except:
    return response['selectedSlot']['message']
    else:
    return "Please try to book an appointment into working hours, which is 10 AM to 7 PM."
    else:
    return "Please provide all the necessary information: Current appointment date, New appointment date, time and email ID."
    except:
    return "We are facing an error while processing your request. Please try again."

    Step 17:

    Next, we will define a function for deleting appointments. This function will first call the ‘get_all_booked_appointments’ function that we created earlier to fetch the corresponding ID of the appointment. The fetched ID will then be passed to the deletion endpoint of the GHL.

    You need to add the below lines of code to define the deletion function:

    def appointment_deletion(arguments):
    try:
    id = get_all_booked_appointment(arguments)
    if id == "Please select valid event number" or id == "No registered event found with this email ID." or id == "We are facing an error while processing your request. Please try again.":
    return id
    else:
    url = f"https://rest.gohighlevel.com/v1/appointments/{id}"
    payload={}
    response = requests.request("DELETE", url, headers=headers, data=payload)
    if response.text == "OK":
    return "Appointment deleted successfully."
    except:
    return "We are facing an error while processing your request. Please try again."

    Step 18:

    Now, we need to define the function specifications for appointment creation, updation, and deletion. These function specifications will be passed to ChatGPT, enabling it to determine which function to invoke based on the user’s argument.

    functions = [
    {
    "name": "appointment_booking",
    "description": "When user want to book appointment, then this function should be called.",
    "parameters": {
    "type": "object",
    "properties": {
    "date": {
    "type": "string",
    "format": "date",
    "example":"2023-07-23",
    "description": "Date, when the user wants to book an appointment. The date must be in the format of YYYY-MM-DD.",
    },
    "time": {
    "type": "string",
    "example": "20:12:45",
    "description": "time, on which user wants to book an appointment on a specified date. Time must be in %H:%M:%S format.",
    },
    "email_address": {
    "type": "string",
    "description": "email_address of the user gives for identification.",
    },
    "phone_number":{
    "type" : "string",
    "description": "Phone number given by user for identification."
    }
    },
    "required": ["date","time","email_address","phone_number"],
    },
    },
    {
    "name": "appointment_updation",
    "description": "When user want to reschedule appointment, then this function should be called.",
    "parameters": {
    "type": "object",
    "properties": {
    "to_date": {
    "type": "string",
    "format": "date",
    "example":"2023-07-23",
    "description": "It is the date on which the user wants to reschedule the appointment. The date must be in the format of YYYY-MM-DD.",
    },
    "date": {
    "type": "string",
    "format": "date",
    "example":"2023-07-23",
    "description": "It is the date from which the user wants to reschedule his/her appointment. The date must be in the format of YYYY-MM-DD.",
    },
    "time": {
    "type": "string",
    "example":"4:00:00",
    "description": "It is the time on which the user wants to reschedule an appointment. Time must be in %H:%M:%S format.",
    },
    "email_address": {
    "type": "string",
    "description": "email_address of the user gives for identification.",
    }
    },
    "required": ["date","to_date","time","email_address"],
    },
    },
    {
    "name": "appointment_deletion",
    "description": "When user want to delete appointment, then this function should be called.",
    "parameters": {
    "type": "object",
    "properties": {
    "date": {
    "type": "string",
    "format": "date",
    "example":"2023-07-23",
    "description": "Date, on which user has an appointment and wants to delete it. The date must be in the format of YYYY-MM-DD.",
    },
    "email_address": {
    "type": "string",
    "description": "email_address of the user gives for identification.",
    }
    },
    "required": ["date","email_address"],
    },
    }]

    Step 19:

    Now, we are ready to test the appointment booking chatbot. You just need to add the following lines of code to run the chatbot.

    day_list = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']

    messages = [{"role": "system", "content": f"""You are an expert in booking appointments, who can fulfill appointment scheduling, rescheduling, and deletion very efficiently. You need to remember the below guidelines while processing user requests.
    Guidelines:
    - You will ask for the appointment date and time, phone number, and email address, when the user wants to book an appointment.
    - When the user wants to reschedule an appointment, then you will ask for the current appointment date, new date and time for the appointment, and email address. If the user didn't remember the current appointment details then inform the user that rescheduling will not be possible without these details.
    - You will ask email address every time, as it is a must for user identification.
    - Don't make assumptions about what values to plug into functions, if the user does not provide any of the required parameters then you must need to ask for clarification.
    - If a user request is ambiguous, you also need to ask for clarification.
    - If a user didn't specify "ante meridiem (AM)" or "post meridiem (PM)" while providing the time, then you must have to ask for clarification. If the user didn't provide day, month, and year while giving the time then you must have to ask for clarification.

    You must need to satisfy the above guidelines while processing the request. You need to remember that today's date is {date.today()}."""}]

    user_input = input("Please enter your question here: (if you want to exit then write 'exit' or 'bye'.) ")
    while user_input.strip().lower() != "exit" and user_input.strip().lower() != "bye":
    messages.append({"role": "user", "content": user_input})

    # calling chat_completion_request to call ChatGPT completion endpoint
    chat_response = chat_completion_request(
    messages, functions=functions
    )
    # fetch response of ChatGPT and call the function
    assistant_message = chat_response.json()["choices"][0]["message"]

    if assistant_message['content']:
    print("Response is: ", assistant_message['content'])
    messages.append({"role": "assistant", "content": assistant_message['content']})
    else:
    fn_name = assistant_message["function_call"]["name"]
    arguments = assistant_message["function_call"]["arguments"]
    function = locals()[fn_name]
    result = function(arguments)
    print("Response is: ", result)

    user_input = input("Please enter your question here: ")

    Testing

    Appointment Booking

    You can see the booked appointments by clicking on the “Calendars” option, under the main menu as shown below:

    Appointment Updation:

    Appointment Deletion:

    In this blog, we explored the process of creating an appointment booking chatbot using OpenAI’s function calling feature. We learned how to integrate the GoHighLevel calendar API, allowing our chatbot to seamlessly interact with the calendar system. This integration enables users to book appointments effortlessly by conversing with the chatbot.

    Originally published at Appointment Booking Chatbot Using OpenAI Function Calling And GoHighLevel Calendar on July 4, 2023.


    Appointment Booking Chatbot using OpenAI Function Calling and GoHighLevel Calendar was originally published in Chatbots Life on Medium, where people are continuing the conversation by highlighting and responding to this story.