1. Guides
  2. Webchat

Guides

Webchat

Setup a chatbot bot using webchat

Initial setup

  1. Create a webchat profile

In this guide we will be using the stubref routing method. Here is more details on other routing methods

  1. Setup create context
  2. Setup default context

Now that you have your basic template setup you can proceed with adding chat bot functionality

Default context

Navigate to default context and click on Edit Flow

  • Add actions _create , _update_from_webchat
  • _create action executes on stub creation. This action will be used to initialize the conversation
  • _update_from_webchat action is executed but the stubber system when a new message is sent from the client

image

  • In _create action add the notification item Webchat notification to session

image

  • In the notification update sessionuuid and webchat_message.value as seen below
        "platforms": {
  "webchat": {
    "sessionuuid": "~~stub.data.webchat_sessionuuid",
    "webchat_message": {
      "type": "markdown",
      "value": "This is a message from create action"
    },
    "stubsession": {
      "set_new_with_timeout_hours": 24 // configures session to be 24 hours
    }
  }
}

      
  • Now your webchat will reply to you with This is a message from create action

image

  • This message will create a link between the webchat session and this stub session for 24 hours
  • All payloads will now be sent to this stub
  • Messages will be automatically placed in stubpost.message

image

  • To respond to further messages add the notification item Webchat notification to session to _update_from_webchat
  • configure the notification as seen below
        "platforms": {
  "webchat": {
    "sessionuuid": "~~stub.data.webchat_sessionuuid",
    "webchat_message": {
      "type": "markdown",
      "value": "This is a message from update_from_webchat action"
    },
    "stubsession": {
      "set_new_with_timeout_hours": 24
    }
  }
}

      
  • Now all future messages from this stubsession will be handled by this stub

Once this set-up is complete you should see the following in your Webchat window:

image