Frequently Asked Questions
You can send SMS messages in a RedwoodJS application by creating a GraphQL mutation that interacts with the MessageBird API. This involves setting up a service to handle the API call logic and defining the mutation in your GraphQL schema. The provided code example uses the MessageBird Node.js SDK to simplify the integration.
MessageBird is a communication platform that provides the SMS API and virtual phone numbers for sending and receiving text messages within your RedwoodJS application. This allows you to add features like notifications, alerts, and customer support interactions via SMS.
ngrok creates a temporary public URL that tunnels HTTP traffic to your local RedwoodJS development server. This is necessary during development so MessageBird's webhook can reach your locally running `messagebirdWebhook` function to test incoming SMS messages before deploying to production.
Verifying the MessageBird webhook signature is crucial for security and should *always* be done, especially in production. This step confirms that incoming webhook requests genuinely originate from MessageBird and haven't been tampered with.
Yes, but be aware of character limits. Standard SMS (GSM-7) allows 160 characters. Using emojis or non-standard characters switches to UCS-2 encoding, reducing the limit to 70 characters. MessageBird handles concatenation for longer messages, but they're billed as multiple parts.
Incoming SMS messages are handled by creating a RedwoodJS function, which acts as a webhook endpoint. This function receives POST requests from MessageBird, verifies the signature, parses the message data, and then processes it (e.g., logging, triggering actions).
A RedwoodJS function serves as the webhook endpoint for receiving incoming SMS messages from MessageBird. It handles the incoming HTTP requests, signature verification, and processing of the received SMS data.
MessageBird requires a 200 OK response from your webhook to acknowledge successful receipt of the message. Failure to respond quickly or returning an error can cause MessageBird to retry sending the webhook, potentially leading to duplicate processing.
If processing inbound SMS messages involves time-consuming operations (database writes, external API calls), perform them asynchronously *after* returning a 200 OK to MessageBird. This keeps your webhook responsive and prevents MessageBird from retrying.
The MessageBird Node.js SDK provides a `webhooks.verify` function for signature verification. Your webhook function must check if the signature is missing from the request, compare it against the signing key (stored securely in environment variables) and return a 401 error if there is an issue with the signature.
The MessageBird originator number is your provisioned virtual phone number, used as the sender ID for outbound messages and the number users reply to for inbound messages. It *must* be in E.164 format (e.g., +14155552671).
You can store SMS message logs using Prisma, RedwoodJS's ORM. Define a model in your `schema.prisma` file to represent the message data (direction, originator, recipient, body, status, etc.) and then use `db.messageLog.create` in your service and function to save the message details.
E.164 (+14155552671) ensures consistent, internationally recognized phone number formatting, crucial for reliable SMS delivery and routing. MessageBird strongly recommends using E.164.
Carriers often mandate handling keywords like STOP, HELP, INFO. Check MessageBird's documentation, sometimes they handle opt-out logic with a STOP keyword. Implement logic in your webhook to process HELP messages (e.g., by sending an automated reply) and to update your database with user preferences if a user texts STOP, preventing future communication.
Content Loading Error
We encountered an error while processing this content.