how to send data to bb webhook,without sharing webhook url to user?

Viewed 90

hello friend i am trying to send data to bb webhook,but i dont want that user see my webhook.

normal bb webhook looks like:

https://api.bots.business/v1/bots/185720/new-webhook?&command=urcommand&public_user_token=eb0943059fb548e9faf1283b536c594e&user_id=846515&redirect_to=https%3A%2F%2Ft.me%2yourbot

i know i can send ajax request to bb webhook by following code:

$.ajax({
    type: "POST",
    url: url,
    data: {
      content: message
    },
    success: success,
    dataType: "json"
  });

But for this i need webhook url for certain user but how to get it anyone knows? if anyone knows answer please.

1 Answers
  1. You can create private webhook for user only. Not for all bot:

code:

let webhookUrl = Libs.Webhooks.getUrlFor({
  // this command will be runned on webhook
  command: "/onWebhook",
  user_id: user.id,
})

So this webhook will be called only for user with user.id It is not available for another user.

  1. We can not hide any information on client side. We can obfuscate it only. But it is not looks good for web request

  2. You can create your own server that will be:

  • receive AJAX request from your web page
  • send request to webhook url

so webhook url will be only in your server side app

Related