Webhook and SMS - sending text, then data, (then text)

Hello,
I have been searching the internet and the discussion board regarding the following and have not found anything that assists with this topic and specifically setting up the Webhook.

A) Sending a data result via SMS
B) Sending a data result with text after it

For example the resulting SMS text would read - “Temperature equals 19 percent”

The code lines are simple:

int data = 19;
Particle.publish(“TEMPERATURE”, String(data), PRIVATE);

When run CONSOLE EVENT LOG shows the event and the data with number 19.

The WEBHOOK setup is as follows
To: - Phone number
From: -Phone Number
Body: -Temperature equals (this is the text to be sent)
Data - data (the data I want to send)
(I have also tried data lower case with data)

The SMS text only sends the body “Temperature equals”. No data is sent with it.

I am also trying to add the word “percent” after the number.

And just for testing the Webhook a different way I have tried adding a second “BODY” to the Webhook for sending additional information after the data but that does not work.

For example:
Body: -Temperature equals (this is the text to be sent)
Data: - data
Body: -percent (to be sent after the data)

Any input or information that can be provided is appreciated.

Hi, and welcome to the community!
What are you using to send the SMS? IFTTT? another service?
Can you post a screenshot of what you configure in said service?
I do not use IFTTT but if someone sees what you are doing maybe they’ll have a clue.
thanks

Hello,

I am using Twilio for sending the SMS.

The only set-up with them is the API / password. I have done some reading on their site (based on your recommendation) and have noticed that the word description in the Webhook set up is the information that is then sent (eg, To and phone number, From and phone number, Body and text). I did try adding “contentVariables” and “data” as an additional row in the Particle Webhook to send the data but that did not work.

Does anyone have any suggestions? Again, I am just trying to send the data (a basic number that was a result) as part of the SMS. For example “Temperature equals 19”. The BODY part of “Temperature equals” gets sent but I can’t get the data result of 19 to be sent.

The code in the program is:
int data = 19;
Particle.publish(“TEMPERATURE”, String(data), PRIVATE);

What happens if you combine the string BODY with the data first, then send it?

Hello,

Twilio Support actually gave the same suggestion.
Per their team, they stated that there isn’t a data parameter available when sending an SMS.

In Python, they suggested appending the data results to a variable, and then as the body of message use an f string and add that variable to the string.

I am working with Adruino in C++.
The code referenced above is:
int data = 19;
Particle.publish(“TEMPERATURE”, String(data), PRIVATE);

The unit sends the “TEMPERATURE” publish to the Particle Webhook.
As stated previously, the Webhook setup is:
To: - Phone Number
From: - Phone Number
Body:- “Temperature equals” (This is the text)

How could I achieve what is being attempted by combining it all as a string?

Note: I am also aware, that there is code summary in the Webhook box that breaks out what is actually being sent from the rows in the Webhook set up. Is that what could be edited?

Any suggestions are appreciated.

String Text;
char EventMsg[40];
Text = "Water";
Voltage = analogRead(A0);
snprintf(EventMsg, sizeof(EventMsg), Text + " Level Detected - ADC=%d", Voltage);
Particle.publish(“TEMPERATURE”, EventMsg, PRIVATE);

I haven’t tested that code, but it should publish a TEMPERATURE event with this payload:
Water Level Detected - ADC=324
324 is whatever the variable Voltage happens to be. In your case, your temp sensor reading.
Make sure your payload does not exceed the length of the EventMsg string. In this case 40 characters.

I send Twilio SMS from a Particle webhook. The easiest way to do it is use the SmsWebhookRK library. Just follow the instructions at that link; the readme explains how to set up the webhook and what to add to your code to make it work.

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.