To create a webhook from scratch, you first have to navigate to the Webhook Builder section of the Data Center and choose Create from Scratch. Following this, we require you to enter information into several fields, which are found below:
Basic Data
In this section, you must enter the name of the webhook and the company that you will be assigning the webhook to. In this case, it's useful to name the webhook in such a way that the purpose of the webhook is not left up to interpretation. Additionally, you will have to pick your preferred type of HTTP request. We support many kinds of HTTP request methods, such as GET, POST, PUT, PATCH, DELETE and more. The next step is to enter the URL for the API Endpoint that you will be using for the webhook.
In the current iteration of the webhook builder, the only Response Type that we support is JSON. We expect to add support for XML in a future iteration. The same holds true for Conversation Execution, where we currently have support for Synchronous Conversation Execution and plan to add support for Asynchronous Conversation Execution in the near future.
The last thing you will need to do is to choose the timeout of the webhook (how long the bot will wait for the external service to respond). The default setting is 5 seconds.
Authentication
In this field, we ask you to enter the type of authentication that the API connected to your URL Endpoint uses. We currently offer three types of authentication: No authentication, Basic authentication, and Bearer authentication.
No authentication means that there will be no authentication of the API connected to your URL endpoint. In this case, there's no authentication information to put in.
Basic authentication is a simple form of authentication that requires that a username and a password for the API is inserted into the fields.
Bearer authentication means that the authentication of the API is based on the bearer token system. This means that there will need to be a security token inserted into the field.
Headers
Headers are responsible for carrying relevant data back and forth. This information can be anything from the type of browser that the user is using to how long you want to keep the connection active. In this field, you can include the information that you deem relevant for the data exchange.
Params
Parameters, or query strings, are a part of the URL that you've selected as your URL Endpoint. With this function, you can either choose to put the parameters directly into the URL Endpoint in Basic Data or enter the parameters into this field.
Context
Context values are only available here when there are {{curly bracket values}} in the URL Endpoint. They can be used to render as specific subdomains when using the WHT for different environments, tenants, accounts, etc.
Body
With most HTTP requests, you will be sending a body along with the request. This is typically the content that you wish to send to the third-party server. The sample JSON below lists all the different variables that you can use to send Bot User or conversation metadata in the message body of the request:
{
"lastName": "{{lastName}}", //Only available in FB channel
"replyData": "{{replyData}}", //Validated Response in a Collector Module
"sessionId": {{sessionId}}, //Unique ID for the conversation
"attachedMedia": "{{attachedMedia}}", //Empty value for now
"direction": "{{direction}}", //"in" or "out". Always "in" for now. "in" if it is a message from the end user to the bot, and "out" if it is a message from the bot to the end user
"reply": "{{reply}}", //Raw user response
"extractedData": {{extractedData|tojson}}, //JSON with previously validated responses
"botId": "{{botId}}", //Bot UUID
"botDeploymentId": "{{botDeploymentId}}", //Bot deployment UUID
"firstName": "{{firstName}}", //Only available in FB channel
"customVariables": {{customVariables|tojson}}, //Previously generated Custom Variables
"moduleId": {{moduleId}}, //Module ID where the WH is triggered
"to": "{{to}}", //Channel ID
"from": "{{from}}", //Bot User External ID
"botTrainedModelId": "{{botTrainedModelId}}" //The UUID string for the NLU model key
}
Run Webhook
Once you've completed all the preceding steps and filled in the required fields, it's time to run your webhook. This is useful, as it allows you to check the result of the Webhook Response, and define and review the custom variables you extract.
Extracted data
In this field, it is possible to define one or more custom variables without needing to run the webhook. The custom variable values are parsed from the Webhook Response using the Jinja2 path added in the 'Response Mapper' field.
In this field, it is possible to add custom variables without needing to run the webhook. These custom variables are stored from the Webhook Response.
Comments
0 comments
Please sign in to leave a comment.