Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1.52 KB

messages.md

File metadata and controls

54 lines (40 loc) · 1.52 KB

Messages

This service provides all that you need to send messages! You just need a template and a customer

Send a Message

Send a message using a templateId or a customer. You can send any json model as a data parameter to be replaced in your template

const notihub = new Notihub({ ...yourKeys });

notihub.messages.send({ 
        templateId: 'your-template-id', 
        customerId: 'your-customer-id',
        force: ['EMAIL'], // optional
        model: {} // optional, value can be any valid json.
    }).then(message => { // Successful response
        console.log(message.messageId);
    }).catch(error => { // Catch error here.
        console.error(error)
    });

Note: force property is optional and gives you the chance to force -no matter what- to send using given DeliveryType, ignoring ContactPreference setting by user. Values: EMAIL, SMS, PUSH

Get a Message

Retrieve a message by id

const notihub = new Notihub({ ...yourKeys });

notihub.messages.get('your-message-id')
    .then(message => { // Successful response
        console.log(message.messageId);
    }).catch(error => { // Catch error here.
        console.error(error)
    });

List Recent Messages

List most messages using pagination

const notihub = new Notihub({ ...yourKeys });

notihub.messages.list({ limit: 10, page: 1})
    .then(messages => { // Successful response
        console.log(JSON.stringify(messages));
    }).catch(error => {  // Catch error here.
        console.error(error)
    });