Developers

Webhook upon saving

Introduction

You can configure your Inbenta Chatbot module to send a POST request to an external service every time an intent is published to “Editing”. Intents can be published to “Editing” using the Editor API or the Intent Editor in a Chatbot instance.

A possible use case for using a webhook with the Editor API is to have the webhook trigger an automatic translation of intents whenever they are published to “Editing”.

Imagine you want to automatically call an external API to machine translate intents as soon as they are saved. To that end, you can configure a webhook to automatically send a POST request to the appropriate API endpoint every time an intent is published to the Knowledge Base. The request payload will contain the intent attributes defined in the saved intent.

You configure this type of webhook in the Settings > General Settings screen of your Chatbot module. For more information on this configuration, see the relevant documentation in the Help Center.

Payloads

Each time a content is published to “Editing”, Inbenta Chatbot will send a POST request to the target URL configured in Settings > General Settings. Such POST requests always have the following payload structure (with application/json encoding):

{ 
     "action": string ["add", "edit"],
     "date": timestamp, 
     "content": { 
         "id": integer, 
         "title": string, 
         "userTypes": {
             "Default": { 
                 attributeName: attributeValue // string or array if multiple 
             }, 
             userTypeName: { 
                 attributeName: attributeValue 
             }, 
         }, 
         "categories": { 
             categoryId: categoryName 
         } 
    }, 
    "currentContent": { 
       "id": integer, 
       "status": integer [1, 2], 
       "title": string, 
       "categories": [integer], 
       "userTypes": [ 
           { 
               "id": integer, 
               "name": string, 
               "active": boolean, 
               "attributes": [ 
                   { 
                        "id": integer, 
                        "name": string, 
                        "objects": [ 
                            { 
                                "id": integer, 
                                "value": string, 
                                "creationDate": date //in ISO format 
                                "createdBy": string, 
                                "modificationDate": date //in ISO format, 
                                "modifiedBy": string, 
                                "useDefault": boolean, 
                                "notShown": boolean, 
                            } 
                        ] 
                   } 
               ], 
               "publicationDate": date // in ISO format, 
               "expirationDate": date // in ISO format 
          }, 
       ], 
       "useForPopular": boolean, 
       "creationDate": date,// in ISO format 
       "createdBy": string, 
       "modificationDate": date, // in ISO format 
       "modifiedBy": string, 
    }, 
    "previousContent": [], // same format as currentContent. Empty when content is new 
}