Author: Franz Malten Buemann

  • Leak reveals the arrival of Sonos voice assistant

    According to code strings shared on reddit the most awaited Sonos Voice Assistant is going to get launched soon……

  • My first experience creating Chatbots

    This week, my first job as a UX Designer in a large company came to mind: Designing and developing a chatbot for one of the sectors of this company.

    I started with a survey about the characteristics and personality that the chatbot would come to have, based on the preferences of those working in the industry. After all, it would be an internal and daily communication about any doubts that might arise on their part.

    During the process, preferences were changing. One moment they wanted a robot, another moment they wanted a robot animal, and ((only)) later they decided that it would make more sense to be a human.

    Another survey was carried to discover their characteristics and personalities. Four more models developed.

    Which would they prefer among the 4 chatbots drawn. One was chosen, but internally it was asked for changes. “Transform it into a super hero.”

    Changes made tho. And two more surveys: the first opened up for suggestions, where we filtered out the ones that would make the most sense, and the second survey, the final choice. What would the name be?

    Sam.

    After that, I started to develop the communication part. Newsletter, presentation video, profile photo and other necessary visual documentation.

    The content process and conversational practices were carried out by the sector itself directly with the developers. In other words, the most important part for a good experience, didn’t have the participation of a UX professional.

    My work ended up creating the chatbot visual.

    Trending Bot Articles:

    1. How Conversational AI can Automate Customer Service

    2. Automated vs Live Chats: What will the Future of Customer Service Look Like?

    3. Chatbots As Medical Assistants In COVID-19 Pandemic

    4. Chatbot Vs. Intelligent Virtual Assistant — What’s the difference & Why Care?

    Even though I was just an intern at the time, I should have shown the importance of my participation throughout the entire process. Today, I would do everything differently following a line of processes that actually work and improve the user experience. My strategy would be based on these 10 topics that I learned:

    1. Define a personality
    2. Heuristics
    3. Prioritize information and create conversations for each context
    4. Define requirements and userflows
    5. Application of good conversational practices
    6. Prototype
    7. Chatbot documentation
    8. Main interaction (URA and NLP)
    9. Define hypotheses, map user needs, prioritize features
    10. Create good conversational user interface practices for each type of channel

    After all, that’s the idea of having a chatbot. Experience.

    Don’t forget to give us your 👏 !


    My first experience creating Chatbots was originally published in Chatbots Life on Medium, where people are continuing the conversation by highlighting and responding to this story.

  • Why your educational institute needs to use a WhatsApp chatbot

    In today’s world, education goes beyond the walls of traditional classrooms. You need to be able to reach and educate your students over the channels that your students use the most. Noting that your students open WhatsApp 23 times daily and spend an average of 28 minutes on it every day, a WhatsApp chatbot would be a powerful tool for your educational institute.‍

    How can WhatsApp chatbots be used for educational institutions?

    Here are some use cases for WhatsApp chatbots in the education industry:

    Driving admissions and enrollments

    You can use your WhatsApp chatbot as a lead generation tool for your educational institute or eLearning platform. It gives you access to prospects on the messaging app they use the most and enables you to answer all their admissions and course-related questions right there without any delays, thus streamlining the enrollment process.‍

    2. Onboarding new students

    New beginnings are always confusing and riddled with anxiety. Students find themselves wondering how things are going to be and how their lives are going to change in their new universities or educational institutes. As an educator, you need to use your WhatsApp chatbot to introduce your students to the new place, make them familiar with the facilities available, their teachers, mentors, and let them know what clubs and committees they can join, as well as the activities that they can participate in.‍

    3. Using it as a Learning Management System (LMS)

    You can go beyond traditional classrooms by using your AI WhatsApp chatbot as an eLearning platform in the form of a learning management system (LMS). These education bots can be used to answer students’ questions, clarify their doubts, and could even be used to teach your students. You could use them to deliver lessons to learners in a conversational format.

    This makes learning fun and interactive. It even gets students invested in the learning process, rather than letting them zone out and spend an hour in their own mental wonderland while pretending to listen to a professor deliver a lecture.

    Since these bots are driven by artificial intelligence, they can even act as mentors for your students, especially during exam season. Picture this — your students are spending the night cramming for an exam and then…. boom, they run into a concept that they just cannot wrap their heads around. You’ve been there too, and your choices were pretty much limited to asking your peers for help (a typical ‘blind leading the blind’ situation), waiting for the morning to ask your instructor about it before the exam, or just skipping the concept, and hoping that your exam did not involve a question about that concept.

    When you use your WhatsApp chatbot as a learning management system, your students get a more effective way to tackle that situation — all they need to do is drop a message on the WhatsApp bot and it will explain the concept whether it’s 11 pm or 5 am.‍

    Trending Bot Articles:

    1. How Conversational AI can Automate Customer Service

    2. Automated vs Live Chats: What will the Future of Customer Service Look Like?

    3. Chatbots As Medical Assistants In COVID-19 Pandemic

    4. Chatbot Vs. Intelligent Virtual Assistant — What’s the difference & Why Care?

    4. Sharing resources

    Your WhatsApp chatbot is definitely an effective way for you to share course materials with your students, but that’s not all that you can do with it. Education shouldn’t be limited to textbooks, and you can’t prepare people for the real world if your lessons stay within the confines of the course material.

    As an instructor, you should share additional resources with your students that can supplement their coursework. Your bot can act as an eLearning platform here, sharing additional resources in the form of rich media or even links.‍

    5. Communications with parents

    Sometimes parents just aren’t in the loop and have no idea about what their kids are doing at school. Education chatbots are a great way for you to keep them informed and not leave them in a state of confusion. Whether it’s about exam results being released, or their children falling short of their attendance threshold, your education chatbot can keep the parents updated, which would be beneficial for teachers as well as students.‍

    6. Broadcasting notifications

    Your Engati WhatsApp chatbot can even be used to send out notifications and announcements by making use of WhatsApp message templates that you could create right over the Engati platform itself.

    What could your educational institution use WhatsApp broadcast messages for?

    1. Admissions lists

    What’s the most annoying thing about checking admissions lists online? Sites just tend to take ages to load up whenever applicants want to check whether they got into the university. It’s a frustrating and anxiety-inducing situation for students.

    WhatsApp chatbots can help you get around this issue.

    When applicants opt-in for messages from your WhatsApp chatbot, you can create campaigns to broadcast messages to them about the admission lists that have been released so that they can easily check whether they’ve gotten into your institution or not.‍

    2. Exam schedules

    Released the schedule for the current exam cycle? You don’t need to put it up on a physical notice board or your website and hope that your students see it. You don’t even need to send an email and wait hours on end for them to open it. All you need to do is push it out on your WhatsApp chatbot as a broadcast message and your students will get a very overt notification.‍

    3. Assignment submissions

    With everything that students have going on with their lives, it’s very easy for them to just forget that they need to submit their assignments. You can use your WhatsApp bot to broadcast messages about the assignment topics when they’re declared, and even to send out reminders when they’re nearing the submission deadline.‍

    4. Extracurricular activities

    Are any of your committees organizing events? Are your sports teams holding tryouts? Maybe you’re organizing a Model United Nations conference?

    A lot of students miss out on extracurricular activities because they simply don’t know that these are taking place or when they are happening. Broadcasting messages to them on WhatsApp helps you deal with this issue, ensuring that everyone knows what’s happening and is offered the opportunity to participate in these activities.‍

    5. Fests

    Let your students know when you’re organizing your college fests or are raising a contingent to participate in another college’s fests. Send messages with lists of the events that your students can sign up for and put their talents in the spotlight.‍

    6. Exam results

    This is always a stressful situation for students. Don’t leave them wallowing in anxiety, wondering when the results will be announced and if they cleared the semester. Just broadcast a message to them via your bot so that they know how they fared.

    You can even send the message with a CTA button that takes them to your website or eLearning portal where they can access individual results confidentially or just send documents over to them directly over your WhatsApp eLearning bot.‍

    7. New lectures uploaded to moodle server

    Never leave your students wondering when they’ll get access to course material. You can use your bot to broadcast messages about new lecture recordings or learning material that has been uploaded to your Moodle server or LMS.

    Best practices for using eLearning WhatsApp chatbots?

    1. Speak your students’ language(s)

    If you’ve got students migrating from their home country to study at your institute or even if you have students learning remotely, you need to engage them in their own language in order to provide them with high-quality education and make sure that they understand their teachers. and mentors.‍

    2. Use bots as well as live chat

    Allow your instructors to teach even beyond traditional classrooms by incorporating bots and live chat. This is especially useful during the exam season and would improve the learning experience.

    You can also use live chat to answer complex administrative queries that the bot could not answer on its own.‍

    3. Go omnichannel

    Reach your students across all the channels that they spend time using. The best way to use chatbots for education is to tie conversations together across all these channels so that your agents always have context and your students don’t have to start the conversation from scratch whenever they switch messaging apps. Engati allows you to engage and educate your students over Facebook Messenger, Instagram, Telegram, and 10+ other messaging applications, in addition to WhatsApp.‍

    How can you create an eLearning chatbot for WhatsApp?

    Building an eLearning chatbot and deploying it on WhatsApp is an extremely easy process, but only when you’re building your bot with Engati.

    All you need is a verified business on Facebook, a WhatsApp Business phone number, the WhatsApp Business API, and the Engati chatbot platform.

    Here’s a quick walk-through on how you can build your WhatsApp chatbot, if you want a more detailed explanation, check out our guide on creating WhatsApp bots.

    This article about “Why your educational institute needs to use a WhatsApp chatbot” was originally published in Engati blogs.

    Don’t forget to give us your 👏 !


    Why your educational institute needs to use a WhatsApp chatbot was originally published in Chatbots Life on Medium, where people are continuing the conversation by highlighting and responding to this story.

  • Need help with chatbot development

    Could you please suggest some resources on chatbot building from the conversational point of view? Best I could find were general tips or outdated information…

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

  • Wie Guided Buying und virtuelle Assistenten Beschaffungsprozesse einfacher gestalten können

    Kennt ihr das auch? Eigentlich sollte ja nur schnell noch Nachschub für die Druckerpatronen bestellt werden. Aber dank des unübersichtlichen Kataloges und den neuen Anforderungen bei der Lieferantenauswahl dauert es mal wieder ewig…

    Richtlinienkonforme Bestellungen für ein Unternehmen aufzugeben ist nicht immer einfach und kann viel Zeit und Nerven kosten. Und am Schluss auch bares Geld, da die Arbeitszeit der Mitarbeiter nun einmal auch vergütet werden muss und langwierige Bestellprozesse so auch die Transaktionskosten in die Höhe treiben.

    In diesem Blog Beitrag erfahrt ihr:

    • Was erschwert Mitarbeiter:innen das Abwickeln von Bestellungen?
    • Was ist Guided Buying?
    • Was sind Chatbots?
    • Wie funktioniert Guided Buying mit einem Chatbot?
    • Was sind die Vorteile von Guided Buying mit Chatbots

    Was erschwert Mitarbeiter:innen das Abwickeln von Bestellungen?

    Mitarbeiter:innen außerhalb des Einkaufs tun sich häufig mit Bestellungen schwer. Oftmals müssen sie eine Vielzahl sehr umfangreicher und nicht immer benutzerfreundlich gestalteter Online-Kataloge durchforsten, um den gewünschten Artikel zu finden. Zudem wissen sie oft nicht, wie sie richtlinien getreu eine BANF anlegen können.

    Dies führt bei den Anforderern immer wieder zu Frustration und vielfach auch zu teuren Freitextbestellungen, die dann von der Einkaufsabteilung bearbeitet werden müssen. Oder die Mitarbeiter:innen kaufen direkt am Einkauf vorbei. Dieses sogenannte Maverick Buying führt dann zu höheren Kosten und anderen negativen Folgen für die Unternehmen.

    Unternehmen können durchschnittlich 24% ihrer Ausgaben einsparen, wenn sie Maverick Buying verhindern. (Wucato)

    Aber auch Einkäufer:innen haben immer wieder mit den Anforderungen bei der Lieferantenauswahl und Bestellprozessen zu kämpfen. Es müssen komplexe und umfangreiche Regularien und Richtlinien beachtet werden, um die Compliance Anforderungen zu erfüllen.

    Hier sämtliche Aspekte, Rahmenverträge, Regularien und Ausnahmefälle auswendig zu können und stets fehlerfrei bei einer Bestellung zu beachten, ist für die Mitarbeiter:innen schlichtweg nicht möglich. Das Nachschlagen in den Regelwerken und Handbüchern kostet die Einkäufer:innen viel zu viel Zeit. 

    Um diesen Mitarbeiter:innen zu helfen, bräuchte es einen persönlichen Assistenten. Jemand, der ihnen das Navigieren dieser Kataloge erleichtert und selbst bei Fragen zum Lieferketten Gesetz die richtige Antwort parat hat. Für jeden Mitarbeiter einen echten, menschlichen Assistenten einzustellen ist natürlich nicht möglich. Aber das ist auch gar nicht nötig. Stattdessen können Unternehmen auf Guided Buying geführt durch Chatbots zurückgreifen:

    Was ist Guided Buying?

    Guided Buying ist eine Assistenzfunktion, die den Anwendern einen effizienten und komfortablen Einkauf ermöglicht. Anforderer und Einkäufer brauchen vor dem Bestellvorgang keine Anleitungen zu lesen, sondern halten automatisch die im Unternehmen festgelegten Beschaffungsrichtlinien ein.

    Für diese Assistenzfunktion können zum Beispiel E Procurement Plattformen genutzt werden. Diese versprechen den Bestellprozess zu vereinfachen, aber im Grunde sind die Mitarbeiter:innen wieder mit einer weiteren komplizierten Aufgabe konfrontiert. Sie müssen auch hier erst einmal lernen mit der Plattform umzugehen und bei Fragen ist immer noch kein Ansprechpartner vorhanden. Sehr viel einfacher geht das mit Chatbots:

    Was sind Chatbots?

    Chatbots sind Dialogsysteme, die es Nutzer:innen ermöglichen, mit einem Bot in natürlicher Sprache zu kommunizieren. Es gibt regelbasierte Chatbots und smarte Chatbots, die mit Hilfe von Machine Learning die Fragen und die Absicht der Nutzer:innen verstehen und beantworten können.

    Die Fähigkeiten von intelligenten Chatbots gehen aber weit über das simple Beantworten von einzelnen Fragen hinaus: Sie können Nutzer:innen durch komplexe Prozesse führen und Informationen abfragen sowie diese in Datenbanken hinterlegen.

    Wie funktioniert Guided Buying mit einem Chatbot?

    Dadurch dass der Austausch mit einem Chatbot in einem Dialog passiert, kann ein Bestellprozess wie ein Gespräch mit einem erfahrenen Kollegen oder Kollegin erfolgen:

    Die Mitarbeiter:innen kontaktieren den Chatbot und teilen ihm mit, was sie bestellen wollen. Mit Hilfe von diversen Fragen holt der Chatbot dann die notwendigen Informationen ein. Er fragt beispielsweise nach der Bestellmenge, dem gewünschten Lieferdatum und anderen Anforderungen, die bei der Bestellung erfüllt werden müssen. 

    Wenn für ein Produkt verschiedene Ausführungen oder Lieferanten im System hinterlegt sind, kann der Chatbot für die Mitarbeiter:innen einen Vergleich vornehmen. Es ist aber auch möglich, dass der Chatbot die vom Unternehmen bevorzugten Produkte und Lieferanten den Nutzer:innen zuerst anzeigt. Des Weiteren kann er Bundles oder Kits vorschlagen. So wird sichergestellt, das miteinander kompatible Produkte bestellt werden.

    In manchen Fällen ist es weniger ausschlaggebend, von welchem Lieferanten das Produkt geliefert wird, sondern vielmehr, ob eine bestimmte Menge zu einem bestimmten Datum zur Verfügung gestellt werden kann.

    Hier kann der Chatbot automatisiert eine Anfrage an die Lieferanten schicken und die Verfügbarkeit des Produktes prüfen. Sobald die Informationen vorliegen, wird der Einkauf informiert und die Mitarbeiter:innen können die Bestellung vornehmen.

    Wenn ein Schritt nicht klar ist, kann der Chatbot ihn erklären und Hilfestellungen geben. Es kann natürlich passieren, dass Nutzer:innen eine Frage stellen, die für die Bestellung selber nicht relevant ist. Zum Beispiel, wie der Status einer anderen Bestellung ist. Derartige Fragen kann der Chatbot beantworten und danach die Nutzer:innen zu dem vorherigen Prozess zurückführen.

    Während des Bestellprozesses sorgt der Chatbot dafür, dass Regularien und Richtlinien eingehalten werden. Wenn Mitarbeiterinnen beispielsweise einen Artikel bestellen wollen, für den keine Freigabe vorliegt, weist der Chatbot darauf hin. Wenn möglich schlägt der Chatbot Alternativen vor, sodass die Bestellung ohne weitere Verzögerung weiter bearbeitet werden kann. Wenn es keine Alternative für den gewünschten Artikel gibt, kontaktiert der Chatbot die Person, die eine Freigabe erteilen kann.

    Dies wäre auch der Fall, wenn die gewünschte Bestellung den maximalen Bestellwert überschreitet. Der Chatbot kontaktiert die verantwortliche Person und kann, sobald die Freigabe vorliegt, die Bestellung eigenständig ausführen. Die Anforderer bekommen in diesem Falle eine Bestellbestätigung per Mail von dem Chatbot zugeschickt. Wenn die Freigabe abgelehnt wurde, werden die Anforderer ebenso von dem Chatbot informiert.

    Es ist auch möglich einen Bestellprozess zu unterbrechen und später wieder fortzuführen. Sei es, weil die Mitarbeiter:innen in ein Meeting müssen oder weil sie noch mit ihrem Vorgesetzten Rücksprache halten wollen. Wenn die Nutzer:innen das Gespräch wieder aufnehmen, kann der Chatbot auf den alten Gesprächsverlauf zurückgreifen und dort wieder anknüpfen. Darüber hinaus kann der Chatbot eine Erinnerung schicken, wenn eine Bestellung noch nicht abgeschlossen wurde.

    Dies ist möglich, weil der Chatbot die einzelnen Personen ihren individuellen Mitarbeiterkonten zuordnen kann. Zu Beginn eines Gesprächs bittet der Chatbot die Nutzer:innen sich einzuloggen. So kann der Chatbot auf sämtliche von der Person bereits getätigten Bestellungen und andere hinterlegte Informationen sowie alte Gesprächsverläufe zugreifen und für die Interaktion mit den Mitarbeiter:innen nutzen.

    Was sind die Vorteile von Guided Buying mit Chatbots?

    Durch den Einsatz von virtuellen Assistenten können Mitarbeiter:innen ohne das Mitwirken der Beschaffung Bestellungen abwickeln. Dadurch dass der Einkauf nur in Einzelfällen herangezogen werden muss, werden die Einkäufer entlastet und haben mehr Zeit für andere Tätigkeiten. Für die Einkäufer selber wird es deutlich leichter richtlinien- und vertragskonforme Bestellungen zu tätigen, da der Chatbot ihnen bei der Anwendung der komplexen Regelwerke hilft.

    Für international agierende Unternehmen eröffnet sich durch den Einsatz von Chatbots die Möglichkeit Prozesse weiter zu beschleunigen. Chatbots sind rund um die Uhr erreichbar und ermöglichen den nahtlosen Austausch von Informationen. Unterschiedliche Bürozeiten sind somit kein Problem mehr.

    Die Akzeptanz einer Guided Buying – Lösung steht in direktem Zusammenhang mit dessen Benutzerfreundlichkeit. Chatbots können komplett ohne Vorkenntnisse bedient werden und können, anders als E Procurement-Plattformen, individuell auf die Nutzer:innen reagieren. Daher bieten sie sich besonders für ein Guided Buying an.

    Wie viel Routineaufgaben an virtuelle Assistenten abgegeben werden und der Grad der Automatisierung der Bestellprozesse kann individuell an die Bedürfnisse und Wünsche von Unternehmen angepasst werden. So kann sichergestellt werden, dass einerseits die Mitarbeiter:innen optimal unterstützt werden, andererseits die MItarbeiter ihre Stärken voll einbringen können. Bei Vertragsverhandlungen mit Fingerspitzengefühl vorzugehen und Lieferantenbeziehung aufzubauen, die auf Vertrauen basieren, können Menschen nämlich immer noch am besten.

    Ihr möchtet wissen, wie ein Bestellvorgang mit einem Chatbot im Detail aussieht? Dann holt euch unser Whitepaper „Guided Buying – Wie mit Chatbots Maverick Buying verhindert werden kann“

    Ihr seid neugierig geworden und wollt wissen, was für andere Anwendungsbereiche es für virtuelle Assistenten in der Beschaffung noch gibt? Dann holt euch unser Whitepaper „Smarte Chatbots im Einkauf“:

    Der Beitrag Wie Guided Buying und virtuelle Assistenten Beschaffungsprozesse einfacher gestalten können erschien zuerst auf BOTfriends.

  • Opensource chatbot for website

    I want to integrate a chatbot into several websites and I am looking for an open source solution that I can host myself (medical websites, privacy issues if I go with a platform that I don’t host).

    I am looking for something like Conversiobot but ideally a solution that would also have a chat functionality – that would allow the users to chat with either the bot or with a human.

    I have LAMP on my servers and that would be ideal but any solution that I can install and configure on my servers would be perfect. Multiuser would be a great bonus (to let users create their own chatbots and chat with users).

    Is there anything like this you would recommend?

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

  • Where can I find an example of e-commerce chatbots using Artificial Intelligence?

    I am writing a thesis for school about trends in e-commerce and I am trying to find an example of an e-commerce business using an AI powered chatbot.

    I can find dozens of sites and a couple of studies about e-commerce using AI powered chatbots but I can’t actually find an example anywhere.

    Only chatbots I can find are those simple ones that can only answer really basic predetermined questions.

    Are there any AI powered chatbots that you know of used in e-commerce or are they just not smart enough yet to be actually used anywhere? What are considered the “smartest” e-commerce chatbots around?

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

  • Expo, React native… on boarding chatbot : Part three

    Expo, React native… onboarding chatbot: Part three

    How onboard user, simply and efficiently.

    Third part of my on boarding chatbot article. It’s gone a be hot, today ! We will put everything working together.
    If you missed the first part,
    it’s over here !
    The second part,
    it’s here !

    In summary for the moment we have, bubbles for the chatbot and the user, animation to simulate the chatbot’s text input.
    We still have to link all these components together, make them communicate.

    React allows us to create contexts, to encapsulate a part of our components to make them communicate with each other.
    We will share in this context a very usefull react hook : UseReducer. This hook will allow us to manage complex state logic.
    Then we will modified the chatbot screen and the bubbles factory to use the state management thought his context and update the app.

    Let’s start by create and initialise a UseReducer.

    UseReducer

    const [state, dispatch] = useReducer(ChatBotReducer, InitialChatBotState)

    UseReducer takes 2 arguments :

    • a reducer function (ChatBotReducer),
    • initial state as input (InitialChatBotState),

    This hooks will returns the current state and a dispatch function as output with array destructuring.

    Too well understand the redux logic, let’s start to talk about state.

    ChatBot State

    UseReducer is the state management solution.

    A state is immutable. It is a picture taken at a given moment. For example our this is our initial State :

    export const InitialChatBotState = {
    currentAction: ChatBotStates.STATE_ONE,
    renderItem: RenderItems.CHAT_BUBBLE,
    showButton: false,
    nextAction: ChatBotStates.STATE_TWO
    }

    It is a object with specific properties who describe our statement.

    The render item used for this state will be chat-bubble , no button and the currentAction is State One for example !

    Now, we have to determine, analyse the Figma board created by the UI / UX team :

    Let’s describe what we have :

    • the chatbot start to write, chatbot bubbles start to be visible.
    • at the end typing a button is showing,
    • Click on the button (here, purple arrows are actions in figma board) and show a user bubble,

    the first bullet is is exactly our initialState ! that’s good !

    For this article part, we won’t follow the board figma above. We will make 2 states in addition to the initial one and put them in a enumeration object :

    export const ChatBotStates = Object.freeze({
    STATE_ONE: 'stateOne',
    STATE_TWO: 'stateTwo',
    STATE_THREE: 'stateThree'
    })

    Trending Bot Articles:

    1. How Conversational AI can Automate Customer Service

    2. Automated vs Live Chats: What will the Future of Customer Service Look Like?

    3. Chatbots As Medical Assistants In COVID-19 Pandemic

    4. Chatbot Vs. Intelligent Virtual Assistant — What’s the difference & Why Care?

    Chatbot Reducer

    The first argument to create a useReducer is reducer (also called a reducing function). this function will manage and centralised all those states.
    Reducers calculate a new state based on the previous state and an action.

    export const ChatBotReducer = (state, action) => {
    switch (action.type) {
    case ChatBotStates.STATE_ONE :
    return {
    currentAction: action.type,
    renderItem: RenderItems.CHAT_BUBBLE,
    showButton: false,
    showModal: false,
    nextAction: ChatBotStates.STATE_TWO
    }
    case ChatBotStates.STATE_TWO :
    return {
    currentAction: action.type,
    renderItem: RenderItems.USER_BUBBLE,
    showButton: true,
    showModal: false,
    nextAction: ChatBotStates.STATE_THREE
    }
    case ChatBotStates.STATE_THREE :
    return {
    currentAction: action.type,
    renderItem: RenderItems.CHAT_BUBBLE,
    showButton: false,
    showModal: false,
    nextAction: null
    }
    }
    }

    This is our reducer called, ChatBotReducer. We find here our 2 new states, with their own particularities. let’s dive in this reducer function.

    A reducer is a function with 2 arguments :

    • State which is the current state with all properties (currentAction, renderItem, etc.).
    • An action is a plain object that represents an intention to change the state. Actions are the only way to get data into the store. Those actions will be dispatched by the dispatch function

    We use a conditional switch / case statement to manage the states in relation to the received action.

    ChatBot Context

    To create our chatbot context we use createContext method form react library. this method have argument, the defaultValue, is usefull when we dont have a provider, but, in our case we will create a provider with a useReducer as value, so we set defaultValue to undefined.

    const ChatBotContext = createContext(undefined)

    export default ChatBotContext

    export function ChatBotProvider ({ children }) {
    const [state, dispatch] = useReducer(ChatBotReducer, InitialChatBotState)
    const reducer = { dispatch, state, ChatBotStates }

    return (
    <ChatBotContext.Provider value={{ reducer }}>
    {children}
    </ChatBotContext.Provider>
    )
    }

    We will use our context in a component, ChatBotProvider. This component is a wrapper, as AnimatedWrapper for the chat-typing component.

    Every Context object comes with a Provider that allows consuming components to subscribe to context changes.
    Provider component accepts a value prop to be passed to consuming components that are descendants of this Provider.

    As you can see, we use the userReducer inside our ChatBotProvider.

    Next, we create a reducer object that includes the dispatch function, the state from the initialisation of useReducer and the list of all states. We pass this reducer object to the props value of the provider.

    This way we share all the tools used to communicate between all components, chat-bubble, user-bubble, bubbles-factory, etc. Chat bot state will be available for each component wrapped in our provider.

    Let’s update the main screen of our app, Chatbot !

    Modify chatbot screen

    const ChatBot = (props) => {
    const [components, setComponents] = useState([])
    const { reducer } = useContext(ChatBotContext)
    const { state, dispatch } = reducer

    useEffect(() => { console.log('ChatBot - props', props) }, [])

    useEffect(() => {
    // console.log('state', state)
    if
    (data) {
    setComponents([
    ...components,
    <BubblesFactory
    data={data.chatBot[state.currentAction]}
    bubble={ComponentsFactory(state.renderItem)}
    interval={state.renderItem === RenderItems.CHAT_BUBBLE ? 3000 : 1500}
    callback={() => {
    state.nextAction && dispatch({ type: state.nextAction })
    }}
    />
    ])
    }
    }, [state])

    return (
    <SafeAreaView style={styles.container}>
    <ScrollView>
    {components.map((component, index) => {
    return (
    <Fragment key={index}>
    { component }
    </Fragment>
    )
    })}
    </ScrollView>
    </SafeAreaView>
    )
    }

    To access to our context we initialise a useContext hooks with a context object (ChatBotContext)

    const { reducer } = useContext(ChatBotContext)

    This will returns the current context value for that context, in our case, the reducer object created in the ChatBotProvider.

    We will retrieve the state and the dispatch function with an array destructuring of the object reducer.

    const { state, dispatch } = reducer

    We will listen our state with the useEffect hooks. The state object contains all the information to update our messages list, data, bubble type to render.

    To facilitate the insertion of components, I have set up a component factory :

    function ComponentsFactory (type) {
    switch (type) {
    case RenderItems.CHAT_BUBBLE:
    return <ChatBubble />
    case RenderItems.USER_BUBBLE:
    return <UserBubble />
    case RenderItems.BUTTON:
    default:
    return <View />
    }
    }

    Modify Bubbles Factory

    I have added a callback to the bubble-factory component. It is used to dispatch the next action sent by the state when there are no more messages to display in the current state.

    The call back method is called in the bubbles-factory in the stopBubbles method.

    End of the day !

    It’s done for today, it was a hard day, understand hooks logics is not easy. i recommended you to play with the code, create your own component, state, etc.

    You can find the all source code here.

    Thank you for taking the time to read this article. Don’t hesitate to leave comments, ask questions, improvements, and play with the code.
    The next part, will be on how to add user interactions using our reducer…

    Don’t forget to give us your 👏 !


    Expo, React native… on boarding chatbot : Part three was originally published in Chatbots Life on Medium, where people are continuing the conversation by highlighting and responding to this story.