Um webhook consiste de:
const WEBHOOK_SECRET = 'webhook secret key';
const crypto = require('crypto');
function verifySignature (body, signature) {
const digest = crypto
.createHmac('sha1', WEBHOOK_SECRET)
.update(body)
.digest('hex');
return signature === digest;
};
app.post('/webhooks', function (req, res, next) {
if (!verifySignature(req.rawBody, req.headers['x-tawk-signature'])) {
// verification failed
}
// verification success
});
const WEBHOOK_SECRET = 'webhook secret key';
function verifySignature ($body, $signature) {
$digest = hash_hmac('sha1', $body, WEBHOOK_SECRET);
return $signature === $digest ;
}
if (!verifySignature(file_get_contents('php://input'), $_SERVER['HTTP_X_TAWK_SIGNATURE'])) {
// verification failed
}
// verification success
WEBHOOK_SECRET = 'webhook secret key';
post '/payload' do
request.body.rewind
body = request.body.read
signature = request.env['HTTP_X_TAWK_SIGNATURE']
unless verifySignature(body, signature))
// verification failed
end
// verification success
end
def verifySignature(body, signature)
digest = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), WEBHOOK_SECRET, body)
return digest == signature
end
Propriedade | Modelo | Descrição |
event | String | Event name `chat:start` |
chatId | String | Chat Id |
time | String | Event generation date time in JSON format |
message | Object | Message object (See below) |
visitor | Object | Visitor object (see below) |
property | Object | Property object (see below) |
Propriedade | Modelo | Descrição |
text | String | Textual representation of message |
type | String | Message type, enum value msg, file, webrtc-call |
sender | Object | Sender info object (See below) |
Propriedade | Modelo | Descrição |
type | String | Sender type, enum value agent, visitor, system |
Propriedade | Modelo | Descrição |
name | String | Visitor name |
String | Visitor email (Optional) | |
city | String | Visitor city |
country | String | Visitor country in ISO 3166 format |
Propriedade | Modelo | Descrição |
id | String | Property Id |
name | String | Property name |
{
event: 'chat:start',
chatId: '70fe3290-99ad-11e9-a30a-51567162179f',
time: '2019-06-28T14:03:04.646Z',
message : {
text : 'Sample message',
type : 'msg',
sender : {
type : 'visitor'
}
},
visitor: {
name: 'V1561719148780935',
email : 'hello@test.com',
city: 'jelgava',
country: 'LV'
},
property: {
id: '58ca8453b8a7e060cd3b1ecb',
name: 'Bobs Burgers'
}
}
Propriedade | Modelo | Descrição |
event | String | Event name chat:end |
chatId | String | Chat Id |
time | String | Event generation date time in JSON format |
visitor | Object | Visitor object (see below) |
property | Object | Property object (see below) |
Propriedade | Modelo | Descrição |
name | String | Visitor name |
String | Visitor email (Optional) | |
city | String | Visitor city |
country | String | Visitor country in ISO 3166 format |
Propriedade | Modelo | Descrição |
id | String | Property Id |
name | String | Property name |
{
event: 'chat:end',
chatId: '70fe3290-99ad-11e9-a30a-51567162179f',
time: '2019-06-28T14:04:08.718Z',
visitor: {
name: 'V1561719148780935',
email : 'hello@test.com',
city: 'jelgava',
country: 'LV'
},
property: {
id: '58ca8453b8a7e060cd3b1ecb',
name: 'Bobs Burgers'
}
}
Propriedade | Modelo | Descrição |
event | String | Event name `ticket:create` |
time | String | Event generation date time in JSON format |
requester | Object | Ticket requester object (see below) |
property | Object | Property object (see below) |
ticket | Object | Ticket object (see below) |
Propriedade | Modelo | Descrição |
name | String | Visitor name |
String | Visitor email (Optional) |
Propriedade | Modelo | Descrição |
id | String | Property Id |
name | String | Property name |
Propriedade | Modelo | Descrição |
id | String | Ticket Id |
humanId | Number | Ticket human Id |
subject | String | Ticket subject |
message | String | Ticket message content |
{
event: 'ticket:create',
time: '2019-06-28T14:07:13.512Z',
property: {
id: '58ca8453b8a7e060cd3b1ecb',
name: 'Bobs Burgers'
},
requester: {
name: 'Martins',
email: 'martins@tawk.to',
type: 'agent'
},
ticket: {
id: '02598050-99ae-11e9-8887-97564881b95b',
humanId: 3,
subject: 'Testing',
message: 'Once more through the breach'
}
}