Reply From Webhook

The 'Reply From Webhook' allows the user to define a call to a Web service that is made when an incoming message arrives, and reply to the message using content provided by the Web service.

You can use this to integrate with a 'Chatbot' service such as http://motion.ai

Fields

The fields required for configuration are as follows

Description.

A helpful label for this webhook. This only appears in the user interface. eg: 'Chatbot'.

Reply Message

The Txt message to send back to the customer. This can include values returned by the Web Service.

eg: Hi {order.customer.name} we have registered your interest in $!{keyword} against $!{from}

Error Reply Message

The message to respond with if an error occurs. Blank for no message. eg: We can't process your request right now. Please try again later, or call us

Address of http Endpoint

What is the URL (address) you would like us to call?

eg: https://api.motion.ai/messageBot?msg=$!{body}&bot=1&session=$!{from}&key=YOUR_API_KEY

Http Verb

What http verb should be used for the request?. eg: GET

Request Body

The body of the httpRequest to send to the webhook

Response Format

The format of the body of the http response. We support JSON, XML, and 'Raw'. This is used to determine how to parse the response, which allows us to provide you with variables such as, for example, {!order#number}. Note that the 'Raw' option means that we perform no processing of the response, therefore the only variable available is '{!raw}', which contains the entire response.

JSON and XML responses can be navigated using a dot notation to traverse any hierarchy, and a hash to access an attribute.

For example, given this XML response:

<?xml version="1.0" encoding="UTF-8"?>
<order number='7' date='1973-01-17'>
   <customer>
      <name>Joe Bloggs</name>
   </customer>
   <phones>
      <phone number='08000001'/>
      <phone number='08000002'/>
   </phones>
</order>

or this JSON response:

{
  "order": {
    "number": "7",
    "date": "1973-01-17",
    "customer": { "name": "Joe Bloggs" },
    "phones": {
      "phone": [
        { "number": "08000001" },
        { "number": "08000002" }
      ]
    }
  }
}

You can extract data from an element using {!order.customer.name}. Support for attributes in XML is dealt with via a hash, eg: {!order#number}. Arrays can be referenced too. eg: {!order.phones.phone[1]#number} (XML) or {!order.phones.phone[1].number} (JSON). Note that they are 1 based, not 0 based.

Http Headers

We allow for four custom HTTP Headers to be provided to the Web Service. eg: 'User-Agent: MyCoolApp 1.0' or 'Ocp-Apim-Subscription-Key: 123123232'.

Variable Formats

The system makes information available via variables that can be used in http requests or reply messages:

Prefix

Source

Property

Content

{!

Data from the web service

{!raw}

The entire content of the Web Service reponse

eg: {!order#number}

Depends on Web Service

$!{

Data from the incoming message

$!{from}

The address the message came from

$!{from-name}

The name of the person that sent the message, when available

$!{to}

The address the message was sent to

$!{body}

The content of the message

$!{keyword}

The first word in the message

$!{keyword-remainder}

All characters after the 'starts with' characters, when 'starts with' is used

$!{args}

All non-keyword words in the message, delimited with 'space'

$!{args-underscore}

All non-keyword words in the message, delimited with '_'

$!{args-dash}

All non-keyword words in the message, delimited with '-'

$!{args-dot}

All non-keyword words in the message, delimited with '.'

$!{args-plus}

All non-keyword words in the message, delimited with '+'

$!{arg1}

The 'nth' word in the message

$!{url-params}

All non-keyword words in the message, urlencoded

$!{public-identifier}

Your identifier for the contact, if available

$!{date.year}

The current year

$!{date.month}

The current year

$!{date.day}

The current day

--

$!{date}

The current date and time, eg: 8/05/2017 4:33:27 PM