2

I am trying to dispatch webhook create endpoint and getting 403 Forbidden response code with no error information in body. My request looks like:

POST /v2/apps/618ce23498488b00e1582723/integrations/618ce235a6ccf400e1a4b992/webhooks HTTP/1.1
Host: api.smooch.io
Content-Type: application/json
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6ImFwcF82MThjZTIzNGZiYTk5MDAwZTFiZDgyYWMifQ.eyJzY29wZSI6ImFwcCJ9.hXigeREGoUQ8YtM_gPUXfgWEGumbnlbBNLk_*******
Content-Length: 120

{
    "target": "https://example.com/inbound-smooch-request",
    "triggers": [
        "conversation:message"
    ]
}

Response I am getting:

{"errors":[{"code":"forbidden","title":"Forbidden"}]}

That's how I generate Bearer token:

$signer = new Sha256();

    $a = (new Builder())
        ->withHeader('alg', 'HS256')
        ->withHeader('typ', 'JWT')
        ->withHeader('kid', 'app_618ce234fba99000e1bd8***')
        ->withClaim('scope', 'app')
        ->getToken($signer, new Key('4K5KoVqLixLOUrkJSebr4rFsvZAu66d2WD8WEhXDgAZnJaltEpnHWpF_PUwQUGuNlFnBXvr8mtGsvNKj******'));
    echo $a . PHP_EOL;
    die();

Webhook api documentation: https://docs.smooch.io/rest/#operation/createWebhook

There is a bearerAuth (integration, app) explanation but there is no information what does this means. Documentation says that there are only two scopes: account and app. So what is this? Other endpoints work normally (app create, app keys create, integration create)

Tried Basic auth also but it did not help.

Vlad Zinko
  • 21
  • 3

1 Answers1

1

The integrations/:id/webhooks endpoints are used (in v2) to create/update/remove webhooks from an existing customIntegration (integration with type: custom).

This endpoint will allow you to create a new integration, and when you set type: custom, it will also accept a list of webhooks: https://docs.smooch.io/rest/#operation/createIntegration create integration > type: custom

Adam Smooch
  • 1,167
  • 1
  • 12
  • 27
  • Thanks for your answer Adam. And if I need webhook for specific integration? For instance WebChat or Telegram. Is it possible to make webhooks for them? – Vlad Zinko Nov 25 '21 at 15:21
  • 1
    All [customer-facing and/or social] channel integrations contribute (inputs) to the same `message pool`. [Custom Integrations and ] webhooks process those messages (regardless of origin) and deliver events to listeners. eg.: if you have a `web` SDK and `Telegram` integrations connected in addition to 1 `custom` integration (listening for `conversation:message` events), your endpoint would receive events for: `web` SDK messages, `Telegram` messages, as well as `business` replies (sent via API). – Adam Smooch Nov 25 '21 at 16:55
  • I have the same issue posted. @AdamSmooch your comment aligns with the text in the docs "Selecting a custom integration allows the creation of webhooks." (see https://docs.smooch.io/rest/#operation/createIntegration). I used the v2 API to create a "custom" integration type which includes webhooks, and confirmed that webhook gets called upon the events I desired like `conversation:message`. It remains curious to me that the UI allows creation of webhooks on non-custom integrations even though the API does not allow this. – josephdpurcell Jun 21 '23 at 00:56
  • Fascinating development: if you use v2 API to create a `custom` integration (which requires specifying webhooks) the integration does NOT show up in the list of integrations. However, the webhooks you specified do show up in the webhooks list. – josephdpurcell Jun 21 '23 at 01:15
  • 1
    Correct - the Smooch dashboard uses the v1.1 API representation where there were 3 distinct classes of integrations: `channels`, `webhooks` and `business systems`. The first 2 are both incorporated into `integrations` in v2 (with `webhooks` becoming integrations with `type:custom`). The latter is not visible via API, and includes native/Zendesk/3rd-party OAuth integrations too. – Adam Smooch Jun 21 '23 at 13:03
  • `It remains curious to me that the UI allows creation of webhooks on non-custom integrations` This doesn't sound right - maybe drop it in a new question or reach out to advocacy for more details? – Adam Smooch Jun 21 '23 at 13:05
  • Thanks Adam! Clarification: when I said "does NOT show up in the list of integrations" I was only checking v1 list of integrations. The v2 list *does* show the custom integration type. – josephdpurcell Jun 23 '23 at 15:50