How can I make alexa discover devices made by Node MCU ESP8266

I wanted to create a project using node mcu and alexa echo device, the first part of the project is where I wanted to know what the alexa is sending to node mcu by writing on serial monitor what node mcu has received from alexa.
The alexa device and the node mcu are on the same wifi network.
Below is my code but I am having a compilation error,
Compilation error: no matching function for call to 'Espalexa::addDevice(String&, void (&)())'
please help me fixing it

#include <ESP8266WiFi.h>
#include <Espalexa.h>

const char* ssid = "ssid";
const char* password = "password";
String requestBody = "Switch";

ESP8266WebServer server(80);
Espalexa espalexa;

void SwitchChanged();

void handleRequest() {
requestBody = server.arg("plain"); // Get the POST data
Serial.println(requestBody);

server.send(200, "text/plain", "Data received");
}

void setup() {
Serial.begin(9600);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");

// Add a virtual device to be discovered by Alexa
espalexa.addDevice(requestBody, handleRequest); // Specify the callback function without parentheses
espalexa.begin();
server.on("/", HTTP_POST, handleRequest); // Specify the callback function without parentheses
server.begin();
}

void loop() {
server.handleClient();
espalexa.loop(); // Include this to handle Espalexa tasks
}

add code tags and all will be revealed (may be)

#include <ESP8266WiFi.h>
#include <Espalexa.h>

const char* ssid = "ssid";
const char* password = "password";
String requestBody = "Switch";

ESP8266WebServer server(80);
Espalexa espalexa;

void SwitchChanged();

void handleRequest() {
requestBody = server.arg("plain"); // Get the POST data
Serial.println(requestBody);

server.send(200, "text/plain", "Data received");
}

void setup() {
Serial.begin(9600);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");

// Add a virtual device to be discovered by Alexa
espalexa.addDevice(requestBody, handleRequest); // Specify the callback function without parentheses
espalexa.begin();
server.on("/", HTTP_POST, handleRequest); // Specify the callback function without parentheses
server.begin();
}

void loop() {
server.handleClient();
espalexa.loop(); // Include this to handle Espalexa tasks
}Use code tags to format code for the forum

I moved your topic to an appropriate forum category @bobby8266 .

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Try with const char * instead of String

➜ check the API

PS: it would have been better to edit the first post - you can still do it…

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