Create Templates

Step 1: Creating a Marketing Template

Endpoint

The endpoint for creating a template is:

/template

Request Body Example for a Marketing Template

{
    "name": "my_template",
    "language": "en_US",
    "category": "MARKETING",
    "components": [
        {
            "type": "HEADER",
            "format": "TEXT",
            "text": "Our {{1}} is on!",
            "example": {
                "header_text": [
                    "Summer Sale"
                ]
            }
        },
        {
            "type": "BODY",
            "text": "Shop now through {{1}} and use code {{2}} to get {{3}} off of all merchandise.",
            "example": {
                "body_text": [
                    [
                        "the end of August",
                        "25OFF",
                        "25%"
                    ]
                ]
            }
        },
        {
            "type": "FOOTER",
            "text": "Use the buttons below to manage your marketing subscriptions"
        },
        {
            "type": "BUTTONS",
            "buttons": [
                {
                    "type": "QUICK_REPLY",
                    "text": "Unsubscribe from Promos"
                },
                {
                    "type": "QUICK_REPLY",
                    "text": "Unsubscribe from All"
                }
            ]
        }
    ]
}

Example Request to Create a Marketing Template

Here is an example request to create a marketing template:

POST https://client.waabot.com/api/v2/template
Content-Type: application/json

{
    "name": "my_template",
    "language": "en_US",
    "category": "MARKETING",
    "components": [
        {
            "type": "HEADER",
            "format": "TEXT",
            "text": "Our {{1}} is on!",
            "example": {
                "header_text": [
                    "Summer Sale"
                ]
            }
        },
        {
            "type": "BODY",
            "text": "Shop now through {{1}} and use code {{2}} to get {{3}} off of all merchandise.",
            "example": {
                "body_text": [
                    [
                        "the end of August",
                        "25OFF",
                        "25%"
                    ]
                ]
            }
        },
        {
            "type": "FOOTER",
            "text": "Use the buttons below to manage your marketing subscriptions"
        },
        {
            "type": "BUTTONS",
            "buttons": [
                {
                    "type": "QUICK_REPLY",
                    "text": "Unsubscribe from Promos"
                },
                {
                    "type": "QUICK_REPLY",
                    "text": "Unsubscribe from All"
                }
            ]
        }
    ]
}

Example Response

Upon successful creation of a template, you will receive a response similar to the following:

{
    "msg": "template created successfully",
    "data": {
        "name": "my_test_template",
        "category": "MARKETING",
        "library_template_button_inputs": [],
        "language": "en_US",
        "components": [
            {
                "type": "HEADER",
                "format": "TEXT",
                "text": "Our {{1}} is on!",
                "example": {
                    "header_text": [
                        "Summer Sale"
                    ],
                    "header_handle": [],
                    "body_text": []
                },
                "_id": "665fb8c106668cd0221d6db3",
                "buttons": []
            },
            {
                "type": "BODY",
                "text": "Shop now through {{1}} and use code {{2}} to get {{3}} off of all merchandise.",
                "example": {
                    "body_text": [
                        [
                            "the end of August",
                            "25OFF",
                            "25%"
                        ]
                    ],
                    "header_text": [],
                    "header_handle": []
                },
                "_id": "665fb8c106668cd0221d6db4",
                "buttons": []
            },
            {
                "type": "FOOTER",
                "text": "Use the buttons below to manage your marketing subscriptions",
                "example": {
                    "header_text": [],
                    "header_handle": [],
                    "body_text": []
                },
                "_id": "665fb8c106668cd0221d6db5",
                "buttons": []
            },
            {
                "type": "BUTTONS",
                "example": {
                    "header_text": [],
                    "header_handle": [],
                    "body_text": []
                },
                "buttons": [
                    {
                        "type": "QUICK_REPLY",
                        "text": "Unsubscribe from Promos",
                        "_id": "665fb8c106668cd0221d6db7"
                    },
                    {
                        "type": "QUICK_REPLY",
                        "text": "Unsubscribe from All",
                        "_id": "665fb8c106668cd0221d6db8"
                    }
                ],
                "_id": "665fb8c106668cd0221d6db6"
            }
        ],
        "status": "PENDING",
        "_id": "665fb8c106668cd0221d6db2",
        "createdAt": "2024-06-05T01:00:49.882Z",
        "updatedAt": "2024-06-05T01:00:49.882Z",
        "__v": 0,
        "id": "665fb8c106668cd0221d6db2"
    }
}

This response indicates that the template creation request was successful and is currently pending approval from Facebook.

Summary

  1. Marketing Template:

    • Used for promotional messages.

    • The request body includes components like HEADER, BODY, FOOTER, and BUTTONS.

  2. Authentication Template:

    • Used for sending authentication messages such as OTPs.

    • The request body typically includes the necessary information for user authentication.

  3. Service Template:

    • Used for service-related messages.

    • The request body includes details pertaining to service updates or notifications.

By following these steps, you can create various types of templates using the Waabot API to cater to your messaging needs.

Last updated