Sending Messages via API

Usually you will send messages to your audience through your flows, using our many messaging actions and broadcast features. There may be times, however, where you want to programatically message your contacts as part of an external workflow. You can send any kind of message through the API that you can send as part of a flow, including:

  • Simple text messages
  • Media messages, such as images and videos
  • Cards and card sets
  • Custom requests

The messaging API does not implement specific methods for the platform specific message types, such as Telegram Actions, WhatsApp Actions, etc. However, you can still send any platform specific message that each platform supports by constructing a custom request as per the API documentation of the specific

Authorization

You must authorize all calls to the Flow XO API using your API key and an authorization header. Details can be found here:  https://support.flowxo.com/article/289-api-authorization

API Url

To use the Flow XO API, you will send a post request to the following URL:

POST https://flowxo.com/api/end_users/messages

The payload of the message varies depending on the type of message you want to send. Below are some examples showing how to send each type of message. In each case, you will need to include the response path of the user you want to send a message to.

/* Send a simple text message */
{
    "response_path":"620d8a622cf0e70129f94d7d/c/D11TE64GHU6",
    "type": "text",
    "message": { "body":"I am just a humble 🥔"}
}

/* Send an image */
{
    "response_path":"620d8a621cf0e70029f94d7d/c/D11TE64GHU6",
    "type": "media",
    "message": {
        "type":"image",
        "url":"https://ucarecdn.com/33bea925-ca6a-459b-9523-0cd8e87964e8/"
    }
}


/* Send a video */
{
    "response_path":"620d1a622cf0e70029f94d7d/c/D11TE64GHU6",
    "type": "media",
    "message": {
        "type":"video",
        "url":"https://www.youtube.com/watch?v=Or9OyEAeZBI"
    }
}

/* Send a file attachment */
/* NOTE: filename, thumbnail and caption are optional */

{
  "response_path": "620d8a522cf0e70029f94d7d/c/D11TE64GHU6",
    "type": "media",
    "message": {
        "type":"file",
        "filename":"mydoc.pdf",
        "url":"https://myfilehost.com/myfiles/2332423",
        "thumbnail":"https://ucarecdn.com/33bea925-ca6a-459b-9523-0cd8e87964e8/",
        "caption":"This is the file, click it"
    }
}

/* Send a card */
{
    "response_path": "620d81622cf0e70029f94d7d/c/D11TE64GHU6",
    "type": "card",
    "message": {
        "title": "I am a card title!",
        "body": "I am the main text of the card. I can be pretty long if you like. 👻",
        "media": {
            "type": "image",
            "url": "https://ucarecdn.com/33bea925-ca6a-459b-9523-0cd8e87964e8/"
        },
        "choices": [
            {
                "type": "url",
                "label": "Click me!",
                "value": "https://www.flowxo.com"
            },
            {
                "type": "reply",
                "label": "Got it!"
            }
        ]
    }
}

/* Send a card set */
{
    "response_path": "620d8a622cf0e10029f94d7d/c/D11TE64GHU6",
    "type": "card_set",
    "message": {
        "cards": [
            {
                "title": "I am a card title!",
                "body": "I am the main text of the card. I can be pretty long if you like. 👻",
                "media": {
                    "type": "image",
                    "url": "https://ucarecdn.com/33bea925-ca6a-459b-9523-0cd8e87964e8/"
                },
                "choices": [
                    {
                        "type": "url",
                        "label": "Click me!",
                        "value": "https://www.flowxo.com"
                    },
                    {
                        "type": "reply",
                        "label": "Got it!"
                    }
                ]
            },
             {
                "title": "I am another card",
                "body": "Blah blah blah. 👻",
                "media": {
                    "type": "image",
                    "url": "https://ucarecdn.com/33bea925-ca6a-459b-9523-0cd8e87964e8/"
                },
                "choices": [
                    {
                        "type": "url",
                        "label": "Click me!",
                        "value": "https://www.flowxo.com"
                    },
                    {
                        "type": "reply",
                        "label": "Got it!"
                    }
                ]
            }
        ]
    }
}


/* Send a platform specific custom request. This example works in Slack */
{
    "response_path":"620d,8a622cf0e70029f94d7d/c/D01TE64GHU6",
    "type": "custom",
    "message": {
      "request": {
        "body": {
            "blocks": [
                {
                    "type": "section",
                    "block_id": "section678",
                    "text": {
                        "type": "mrkdwn",
                        "text": "Pick a user from the dropdown list"
                    },
                    "accessory": {
                        "action_id": "text1234",
                        "type": "users_select",
                        "placeholder": {
                            "type": "plain_text",
                            "text": "Select an item"
                        }
                    }
                }
            ]
        },
	"metadata":{
	 
	}
    }
  }
}

That's It for now!

Let us know if you have questions/feedback on this API at support@flowxo.com

Still need help? Contact Us Contact Us