Message text to send as if from the bot
Callback function to be executed once the user replies (optional)
Opens the chat window (if not already open) and sends a message to the bot as if from the user. Executes the optionally-provided callback function when the bot replies to the message. The bot will not "know" the difference between this message and a message genuinely sent from the user.
Usage
Message text to send as if from the bot
Callback function to be executed once the user replies (optional)
Opens the chat window (if not already open) and sends a message to the user as if from the bot. Executes the optionally-provided callback function when the user replies to the message (if they do so). Note: the bot will not "remember" that it sent this message, so any user replies will cause the bot to continue where it left off before this message was sent.
Usage
// Send a message to the user saying "Hello!" as if from the bot Otis.messages.sendAsBot("Hello!"); // Send a message to the user saying "Hello!" as if from the bot, and then // log details about their response to the console when they reply Otis.messages.sendAsBot("Hello!", (event) => { console.log("User said:", event.data.text); console.log("At:", new Date(event.data.timestamp)); if (event.data.freeform) { console.log("(they sent this message by typing into the text box)"); } else { console.log("(they sent this message by clicking a button)"); } });