Bots

Webhooks

What are webhooks?

Webhook's are a method for websites and applications to communicate with each other in real-time. They enable seamless integration between different platforms by sending data instantly when a specific event occurs. Instead of constantly polling for updates.

How do I setup webhooks?

Webhook's are configured per bot so first visit https://chatthing.ai/app/bots to select a bot & click the tab for Webhooks. Then, to add a new webhook click the Setup button.

webhook-setup.png

Available webhooks

Sync trigger hook

This hook allows a remote system to trigger a sync on one of your bots data sources.

sync-trigger-hook.png

For this hook, you'll need to select a data source via the dropdown.

sync-trigger-hook-select-data-source.png

Once you've made a selection, click the Create button, this will generate a unique url for this hook. Making a GET request to this URL will trigger a sync.

curl --request GET \
  --url https://chatthing.ai/api/public/hooks/38362dae-a2b4-4484-8ced-920082a40b45/14e6c7131ce0465cb46ec109e7de0719

Response

The response will include the following information:

  • success (boolean): Indicates whether the request was successful or not.

Example response:

{
	"success": true
}

Always keep this URL secret since anyone who has it, can trigger a sync against your data source. Remember you can change the hook secret at any time & doing so, will invalidate any previously generated URL's. You can enter your own secret or click the icon to the right of the input to automatically generate a new secret.

change-hook-secret.png

After clicking the Update button, the previous URL will be invalidated and a new URL generated in it's place, be sure to use the new url going forward.

Sync success hook

This hook allows a remote system to receive an event indicating a data source was synced successfully. If you don't specify a data source you'll receive an event via this webhook when any of the bots data sources sync successfully. If you select a data source then the hook will only receive an event when the specified data source is successfully synced.

sync-success-webhook.png

💡

To get up and running quickly why not take advantage of the following site https://webhook.site it generates a unique url which you can use to check event is triggered as you expect.

After providing a target URL click the Create button to setup the hook.

sync-success-webhook-setup.png

Hook payload

The target URL you provided for this hook will receive a POST containing the following JSON structure.

  • success (boolean): Indicates whether the request was successful or not.
  • results (object): structure explaining
    • totalTokens (number): the total number of storage tokens consumed by this sync
    • modifiedRows (number): the number of rows which have changed since the last sync
    • totalDocuments (number): the total number of individual documents relating to this data source
    • unmodifiedRows (number): the number of rows which haven't changed since the last sync
    • totalDataSourceRows (number): the number of data source rows
  • bot (string): the name of the bot
  • dataSource (string): the name of the data source

Example body:

{
  "success": true,
  "results": {
    "totalTokens": 241245,
    "modifiedRows": 15,
    "totalDocuments": 20,
    "unmodifiedRows": 0,
    "totalDataSourceRows": 15
  },
  "bot": "Testing bot",
  "dataSource": "Data source one"
}

Sync failure hook

This hook allows a remote system to receive an event indicating a data source experienced an issue during syncing. If you don't specify a data source you'll receive an event via this webhook when any of the bots data sources fail to sync. If you select a data source then the hook will only receive an event when the specified data source fails to sync.

sync-failure-webhook.png

💡

To get up and running quickly why not take advantage of the following site https://webhook.site it generates a unique url which you can use to check event is triggered as you expect.

After providing a target URL click the Create button to setup the hook.

sync-failure-webhook-setup.png

Hook payload

The target URL you provided for this hook will receive a POST containing the following JSON structure.

  • success (boolean): Indicates whether the request was successful or not.
  • reason (string): the reason why your data source failed to sync
  • bot (string): the name of the bot
  • dataSource (string): the name of the data source

Example body:

{
  "success": false,
  "reason": "Over plan storage token limit, please upgrade plan",
  "bot": "Testing bot",
  "dataSource": "Data source one"
}

Didn't find what you were looking for? We're always looking to improve Chat Thing, so if you need a webhook which isn't described above please email us: [email protected]