Using Web Hook as a channel in Synchronous and Asynchronous Integration modes / How to use and integrate Kore API's

@arulvelug Could you please create a new app, associate the new app with the webhook channel and republish the bot along with the channel?

Yes, ‘from’ and ‘to’ keys are mandatory in the payload.

Regarding your use case, please check if the below configuration could help (Provided, service now offers an endpoint to poll the status of ticket)

  1. Create a web service alert in the bot which notifies the user about the ticket status updates.
  2. In the dialog which is used to raise the service now ticket, configure the web service alert as a smart alert at a service node.
  3. During the runtime, in the dialog wherein service now ticket registration happens, when the service node at which the smart alert is configured is executed, an alert instance is created at the user.
  4. This alert instance polls the service as defined at the alert based on the scheduled frequency and would push alert notifications to the user based on the received response.

Hello, I’m trying to test the syncronus webhook with postman, but always i get “Invalid access” as response, maybe i have problems with the authorization token. I’m using a python script to generate the token. I’m not sure what value I must put on “sub” in the JWT Payload is any random number? also where i must use the secret code?

{
“appId”: “{{clientId of the bot}}”,
"sub" : “{{random number}}” <— ? any random number? as string or int?
}

this is my python script:
import jwt

client_id = 'cs-088a753a-a8fe-58b7-bfbe-ab5801e3b9ea'
random_num =  '12345'

my_token = jwt.encode({
  "appId": client_id,
  "sub" :  random_num
  }, 'secret', algorithm='HS256')

print(my_token)

@laros Could you please check and confirm if the webhook channel has been published? Also, could you please share the cURL so that we could debug further?

The webhook channel is configured but mi bot isn’t published yet the status is in-development". Webhook channel are only available on published bots? I used “cheat developer on” in the bot chat.

thanks for your help :slight_smile:

curl -X POST
https://bots.kore.ai/chatbot/hooks/st-8a35228a-fa72-5c80-b311-37ab234a1497
-H ‘Accept: /
-H ‘Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcHBJZCI6ImNzLTA4OGE3NTNhLWE4ZmUtNThiNy1iZmJlLWFiNTgwMWUzYjllYSIsInN1YiI6IjEyMzQ1In0.ZF5OYUB50LnogdUE1T9sozQJ9dE6IDlKTLF-oZ1v1sM’
-H ‘Cache-Control: no-cache’
-H ‘Connection: keep-alive’
-H ‘Content-Type: application/json’
-H ‘Host: bots.kore.ai’
-H ‘Postman-Token: 324e1e02-0638-4407-9448-c2cf0d80977e,a139e540-979a-4238-93ab-cc94ad42cb46’
-H ‘User-Agent: PostmanRuntime/7.15.0’
-H ‘accept-encoding: gzip, deflate’
-H ‘cache-control: no-cache’
-H ‘content-length: 28’
-d '{
“text” : “Hola”
}

Hi @laros , The payload you are passing to the hook URL seems to be incorrect. You will need to include the from and to IDs in the body.

Please refer to the cURL mentioned here:

@arulvelug The webhook alerts cannot be configured as the webhook instance might change dynamically for a user to the user. Also, in your case, the user should not explicitly configure/invoke the alert. The bot should automatically inform the user in case of ticket status change. Hence, we are suggesting to use smart alerts and there is no other way to avoid polling to the service.

To explain how it dynamically changes for User to User with a scenario where webhook alerts can be configured.

We create an alert task with “Connection Type” as “Webhook” and provide the sample response in the “API request” tab and Finish the alert set up in the platform.

Now, when a user is communicating to the bot and the alert is configured by the user, then a Webhook URL will be exposed to the user in the chat window.

User needs to configure this Webhook URL in the external 3rd parties to get updates whenever changes are made at the 3rd party end.

For example, I as a developer would create a webhook alert when I have a use-case where the end-user would configure(Trigger) the alert in the bot as per his/her need with an external service.
So as mentioned above, when the user configures the alert, they would receive a Webhook URL from the bot.

They need to set this URL in the 3rd party service(like JIRA) to get constant updates from it. (Every service like JIRA, BitBucket, Git, etc have the developer documentation to set up these Webhook URLs with them).

The Webhook URL that is given to the user changes from user to user and instance to instance. You can observe that the webhook URL below is different from the above screenshot.

For your use-case where you would like to send alerts to the user in case of ticket status change, etc, this webhook alert functionality which is currently available will not be suitable.
Hence, we are suggesting to use smart alerts and there is no other way to avoid polling to the service.

Could you please confirm whether webhook channel has to be publish? Will it work if it’s only configured?

@leena8feb
As per current design, web-hook channel(s) needs to be published in order to communicate.

Hi followed the examples step by step and I’m getting “Invalid access Token” always! I need to send the access token anywhere in my post request?

Please copy your cURL here.
Also, please ensure you have signed the jwt token using client secret as defined in the app for webhook channel.

curl --location --request POST ‘https://bots.kore.ai/chatbot/hooks/st-61ef1943-b2ce-52a2-9531-3a48d5c01dad
–header ‘Content-Type: application/json’
–header ‘Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcHBJZCI6ImNzLTQ0NWRkZDk4LWMwNzMtNTQ3Yi1iOGFjLWU1MzQ5MDM3NjA5MSIsInN1YiI6IitHLzJHaGxiT3NRSWxqMnNHY0l3N0RiTDc4aU40dHY3NWpMUVVQV3FhZjA9IiwiYWNjZXNzVG9rZW4iOiJxd2VydHkxMjMiLCJqdGkiOiI4NzI3NDYwMi0xMjY2LTQwZGItYmI0NS04YzJhM2Q2ZGNjZmIiLCJpYXQiOjE1OTUzMzAwMTQsImV4cCI6MTU5NTMzMzYxNH0.EctZ6GpC7mZFpOy7rEHR80W2bay56MxzqowkhYmq6bg’
–data-raw ‘{
“text”: “hi”
}’

@ruben.costa

I see that your JWT has JTI. If that is the case, Platform will not allow same JWT token again.
Only sub and appId in the payload matter anyway.

{
“sub”:"koresupport@kore.com",
“appId”: “cs-e2XXXXXXXXX1-7c94-553b-9d97-66XXXX40a”
}

Use the below in body

{
        "message":{
			"text" : "UTTERANCE"
		},
        "from" :{
            "id": "a@b.com"
		},
        "to" :{
            "id": "st-59d0XXXXXBOT-IDXXXXX04a0cde8a1"

		}
}


Sorry but still missing something.

Let me share all my steps:

  1. Create a JWT token with the follow payload:
    {
    “appId”: “cs-445ddd98-c073-547b-b8ac-e53490376091”,
    “sub” : “+G/2GhlbOsQIlj2sGcIw7DbL78iN4tv75jLQUPWqaf0=”
    }

  2. The integration mode is Synchronous

  3. in the postman, I use the Authorization Bearer Token and past te JWT token:
    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6ImNzLTQ0NWRkZDk4LWMwNzMtNTQ3Yi1iOGFjLWU1MzQ5MDM3NjA5MSIsInN1YiI6IitHLzJHaGxiT3NRSWxqMnNHY0l3N0RiTDc4aU40dHY3NWpMUVVQV3FhZjA9In0.NOZkuSp67M3Efu29ka8O-fASQoo3W4Qa9lw9cz3swFM

  4. I’m doing a post to this URL https://bots.kore.ai/chatbot/hooks/st-61ef1943-b2ce-52a2-9531-3a48d5c01dad

  5. the body I’m using what you gave me
    6 ) Result: invalid access token

@ruben.costa
While creating jwt I hope you signed the same with secret key. Please confirm. And if that is also done, please send me the secret in email swagata.sengupta@kore.com to take a look.

The webhook call was working fine ,but from past 2 days the request is getting timed out

@chatbotcognigy56,

Please send us the appropriate screenshots.

Regards,
Yoga Ramya

This is resolved now, thanks for the response

Hi @Subrahmanyam- I followed the same approach for the asynchronous method , but looks like the webhook call fires the request twice , the same request is firing twice when we tested from postman

webhook

@swagata.sengupta @Subrahmanyam

I have an enterprise bot that expects to receive the below customData fields through WEB/Widget SDK channels

KoreSDK.chatConfig.botOptions.botInfo.customData.firstName = firstName;
KoreSDK.chatConfig.botOptions.botInfo.customData.lastName = lastName;
KoreSDK.chatConfig.botOptions.botInfo.customData.login = login;
KoreSDK.chatConfig.botOptions.botInfo.customData.email = email;
KoreSDK.chatConfig.botOptions.botInfo.customData.phone = phone;

I also need to invoke the same bot through Synchronous Webhook channel and pass the same fields identifying the user. How do I pass the customData through the POST message payload

image

@harshal.mulherkar At the same level as message, from etc. pass on any other name value pair. They all should be available under BotUserSession lastmessage key.