Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code snippet on how to create a webhook using the MessageMedia Webhooks Node.js SDK.
function createWebhook(){
var controller = setup();
// Create body of your webhook
var body = new lib.CreateWebhookRequest({
"url": "http://webhook.com", // URL of the webhook
"method": "POST", // HTTP method
"encoding": "JSON", // Content type of the request
"events": [
"RECEIVED_SMS" // Webhook subscribed to RECEIVED_SMS event which is triggered when an SMS is received
],
"template": "<id>$mtId</id>, <time_sent>$submittedTimestamp</time_sent>, <time_received>$receivedTimestamp</time_received>, <account_id>$accountId</account_id>" // The attributes in the template will be returned when the webhook is triggered
});
// Call the function that creates the webhook
controller.createWebhook(body, function(error, response, context) {
console.log(response);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.